psd.c
上传用户:poi891205
上传日期:2013-07-15
资源大小:9745k
文件大小:45k
- /**************************************************************************
- * *
- * Copyright (c) 2002 by Sunplus Technology Co., Ltd. *
- * *
- * This software is copyrighted by and is the property of Sunplus *
- * Technology Co., Ltd. All rights are reserved by Sunplus Technology *
- * Co., Ltd. This software may only be used in accordance with the *
- * corresponding license agreement. Any unauthorized use, duplication, *
- * distribution, or disclosure of this software is expressly forbidden. *
- * *
- * This Copyright notice MUST not be removed or modified without prior *
- * written consent of Sunplus Technology Co., Ltd. *
- * *
- * Sunplus Technology Co., Ltd. reserves the right to modify this *
- * software without notice. *
- * *
- * Sunplus Technology Co., Ltd. *
- * 19, Innovation First Road, Science-Based Industrial Park, *
- * Hsin-Chu, Taiwan, R.O.C. *
- **************************************************************************/
- /*--------------------------------------------------------------------------
- | File Name : psd.c
- |
- | Description : .... VCD 2.0 psd functionality..
- |
- | Version : 0.1
- |
- | Rev Date Author(s) Status & Comments
- |-----------------------------------------------------------------------------------------
- | 0.1 Creating
- | 0.1 2004/11/30 Linrc Add Comments
- |-----------------------------------------------------------------------------------------*/
- #include "config.h"
- #include "global.h"
- #include "macro.h"
- #include "regmap.h"
- #include "util.h"
- #include "memmap0.h"
- #include "func.h"
- #include "cdfunc.h"
- #include "vfdfunc.h"
- #include "stc.h"
- #include "cfont.h"
- #include "osd.h"
- #include "psd.h"
- #include "svcd.h" //Jeff 20010717
- #include "image.h"
- #include "fs96602.h"
- #include "stdlib.h"
- #include "user_if.h"
- #include "misc.h"
- #include "fsnav.h"
- #include "NesInit.h"
- #include "kernel.h"
- #ifdef SP1000_NO_DVD
- #include "psd_null.c"
- #else
- //#define AU_REGS ((volatile struct au_regs *)regs0)
- /*************************************************/
- #ifndef DVDRELEASE
- //#define MONE_PSD
- //#define MONE_PSD_READ
- //#define MONE_PSD_LIST_CONTENT
- //#define SHOW_PSD_WAITING
- #endif
- #ifndef MONE_PSD
- #undef printf
- #undef print_block
- #define printf(f, a...) do {} while (0)
- #define print_block(x,y) do {} while (0)
- #endif
- #define psd_epp_write(s) epp_write_wait(s)
- //
- // FUNCTION
- // rand()
- //
- #define rand() (regs0->stc_15_0)
- //
- // PSD_MSF
- //
- // default PSD start MSF address in VCD 2.0
- //
- #define PSD_MSF MSF(0,4,34)
- #define List (pFsJpeg->List)
- /**************************************************************************
- * Function Name: int psd_getlist(int ListID) *
- * Purposes: *
- * read a specified PSD list-table(play-list/selection-list...) *
- * into memory *
- * Descriptions: *
- * read a specified PSD list-table into memory *
- * Arguments: *
- * Input: ListID --> The PSD list ID that will play... *
- * Returns: 0->Get play list ID OK; *
- * 1->Get list fail turn back to PBC off *
- * See also: None *
- **************************************************************************/
- int psd_getlist(int ListID)
- {
- int length;
- UINT8 *p;
- UINT32 offset = ListID * psd_st.psd_offset_multiplier;
- //
- // read in list
- //
- rep_run_this_menu=0;//terry,new setup menu to recover menu,0508
- p=wb_loc(msf2l(PSD_MSF),offset);
- if(nav_data_err==0)
- memcpy((BYTE *)&List,p,8);
- else
- List.s.header=0;
- //
- // load specific length of reset of data
- //
- // for play-list
- // for selection-list
- //
- if (List.s.header==0x10)
- {
-
- // play-list 2*NOI+14
- length = 2*List.p.noi + 14;
- if(List.p.noi==0){//wangap add 2004/12/29
- length = 8; //when the list data is wrong eg.for some bad vcd20 disc
- return 1; //we just jump the list to play(as get list fail turn back to PBC off)
- }
- #ifdef MONE_PSD_READ
- psprintf(linebuf, "PLAY %x %xn", ListID, length);
- psd_epp_write(linebuf);
- printf("PSD PLAY LIST-ID %x length %xn", ListID, length);
- #endif
- }
- else if( (List.s.header==0x18)||(List.s.header==0x1a) )
- {
- // selection-list 2*NOS+20
- length = 2*List.s.nos + 20;
- #ifdef MONE_PSD_READ
- psprintf(linebuf, "SELECT %x %xn", ListID, length);
- psd_epp_write(linebuf);
- #endif
- }
- else if (List.s.header==0x1f)
- {
- // end-list -> the 8-byte read are enough
- length = 8;
- #ifdef MONE_PSD_READ
- psprintf(linebuf, "END %x %xn", ListID, length);
- psd_epp_write(linebuf);
- #endif
- }
- else
- {
- length = 8;
- #ifdef MONE_PSD_READ
- printf("list %x %xn", ListID, length);
- #endif
- return 1; //Terry 891005 get list fail turn back to PBS off
- }
- //do_cdrom_read_msf(((BYTE *)&List), PSD_MSF, offset, length);//kenny mark it
- memcpy((BYTE *)&List,p,length);
- #ifdef MONE_PSD_LIST_CONTENT
- {
- int i;
- for (i=0; i<length;)
- {
- // psprintf(linebuf, "%02x",((BYTE *)&List)[i]);
- // psd_epp_write(linebuf);
- printf( "%02x",((BYTE *)&List)[i]);
- i++;
- //if ((i&0x0f)==0) psd_epp_write("n");
- if ((i&0x0f)==0) printf("n");
- }
- //psd_epp_write("n");
- printf("n");
- }
- #endif
- //delay(5000);
- switch(play_state)
- {
- case VCD_STATE_POWER:
- case VCD_STATE_STOP:
- case VCD_STATE_OPEN:
- return 1;
- }
- return 0;
- }
- /**************************************************************************
- * Function Name: int psd_play_item(int item) *
- * Purposes: *
- * prepare for a PSD item playback. *
- * Descriptions: *
- * The playback PSD item is track-number or entry-id or segment_id *
- * Arguments: *
- * Input: item --> Playback item ID *
- * 0-1 none *
- * 2-99 track-number *
- * 100-599 entry_id + 100 *
- * 600-999 <reserved> *
- * 1000-2979 segment_id + 1000 *
- * Returns: -1->item is wrong; *
- * -2->item nomber out of range *
- * 0 ->play item *
- * See also: None *
- **************************************************************************/
- int psd_play_item(int item)
- {
- UINT8 new_psd_state =psd_state& 0xf0;
- item=getUINT16_bi(&item);
- //
- // check if item is valid
- //
- //psd_st.psd_item_no = item;
- ClearCommand();//terry,move to this by DTS check ,maybe it's worng?
- //printf("item:%xn",item);
- if (item<2)
- {
- return -1;
- }
- else if (item<100)
- {
- // check track
- if (item>cd_trk_hi)
- return -2;
- psd_state = new_psd_state | PSD_PLAY_TRACK;
- }
- else if (item<600)
- {
- // check entry-point
- int entries = get_entry(0) & 0xffff;
- if ((item-99)>entries) return -2;
- psd_state = new_psd_state | PSD_PLAY_ENTRY;
- }
- else if (item<1000)
- {
- return -1;
- }
- else if (item<2980)
- {
- // check valid-segment
- BYTE seg_code = get_segment(item-999);
- if ((seg_code&0x1f)==0) return -2;
- psd_state = new_psd_state | PSD_PLAY_SEG;;
- }
- else
- {
- return -1;
- }
- if(goto_active==1)
- {
- s_msf=goto_time&0x00ffffff;
- PlayLBA(msf2l(goto_time),0);
- }else
- if (item<100)
- {
- //
- // ITEM: 1-99
- // playback a track (item)
- //
- PlayTrack(item);
- }
- else if (item<600)
- {
- //
- // ITEM: 1-99
- // playback an entry (item-99)
- //
- PlayEntry(item-99);
- }
- else if (item<2980)
- {
- //
- // ITEM: 1000-1999
- // play segment (item-999)
- //
- //printf("=====PLAY SEGn");/*jhuang 891108*/
- PlaySegment(item-999);
- }
- // PictureCounter = 0;
- return 0;
- }
- /**************************************************************************
- * Function Name: int psd_timeout_value(int time) *
- * Purposes: *
- * get the real time base on the timeout_value. *
- * Descriptions: *
- * This function call by psd timeout(),it return the real time out time *
- * Arguments: *
- * Input: time --> 0-60 t seconds *
- * 61-254 60 + 10 * (t-60) seconds *
- * 255 forever *
- * Returns: 0-254->real time(seconds) *
- * 255->0 *
- * See also: None *
- **************************************************************************/
- int psd_timeout_value(int time)
- {
- int s;
- int t;
- t = 0;
- if (time!=0x00ff)
- {
- if (time<=60)
- s = time;
- else
- s = time*10 - 540;
- //t = (RTC_TICKS * s) / 16 + 1;
- t = (RTC_TICKS * s) + 1;//kenny 2001/7/27
- }
- return t;
- }
- /**************************************************************************
- * Function Name: int psd_search_entries(UINT32 msf_now) *
- * Purposes: *
- * search psd entries. *
- * Descriptions: *
- * search entries from entry n to entry 0 *
- * Arguments: *
- * Input: msf_now --> msf entry now *
- * Returns: entry *
- * See also: ENTRY-n ENTRY-o *
- * +-------------+ *
- * msf_now *
- **************************************************************************/
- int psd_search_entries(UINT32 msf_now)
- {
- int entries;
- msf_now = msf_now & 0x00ffffff; // don't compare TRK ??
- entries = get_entry(0) & 0x0000ffff;
- while (entries>0)
- {
- UINT32 msf = get_entry(entries)&0x00ffffff;
- if (msf > msf_now)
- entries--;
- }
- return entries;
- }
- /**************************************************************************
- * Function Name: UINT32 psd_callback_check(UINT32 func) *
- * Purposes: *
- * Check the IR_CMD function. *
- * Descriptions: *
- * filter out special keys *
- * Arguments: *
- * Input: func --> cmd *
- * Returns: Cmd after function check *
- * See also:CMD:CMD_FUNC_PLAY CMD_FUNC_DEFAULT CMD_FUNC_NEXT *
- * CMD_FUNC_PREV CMD_FUNC_RETURN *
- **************************************************************************/
- UINT32 psd_callback_check(UINT32 func)
- {
- int c = func&0x00ff00;
- int bit15=0;
- if (c == CMD_FUNC)
- {
- c = func&0x00ff;
- if (List.p.header==LIST_PLAY)
- {
- //psd_state = PSD_PLAY_LIST;//terry , mark it,2001/10/2 09:26PM ,it will damage psd state machine
- //
- // PLAY: no-effect
- // PREV: select list_prev
- // NEXT: select list_next
- // RETURN: select list_return
- //
- if(c==CMD_FUNC_PLAY)
- func=0;
- else if(c==CMD_FUNC_NEXT)
- {
- psd_st.psd_item_loop++;
- if(psd_st.psd_item_loop>=List.p.noi)
- {
- bit15=List.p.list_next;
- if(bit15&0x80)
- psd_st.psd_item_loop--;
- }
- }else if(c==CMD_FUNC_PREV)
- {
- if(psd_st.psd_item_loop==0)
- bit15=List.p.list_prev;
- }else if(c==CMD_FUNC_RETURN)
- bit15=List.p.list_return;
- }
- else if (List.p.header==LIST_SELECTION)
- {
- //psd_state = PSD_SEL_LIST;
- //
- // PLAY: select list_default
- // PREV: select list_prev
- // NEXT: select list_next
- // RETURN: select list_return
- //
- if(c==CMD_FUNC_NEXT)
- bit15=List.s.list_next;
- else if(c==CMD_FUNC_PREV)
- bit15=List.s.list_prev;
- else if(c==CMD_FUNC_RETURN)
- bit15=List.s.list_return;
- else if( (c==CMD_FUNC_DEFAULT)||(c==CMD_FUNC_PLAY) )
- bit15=List.s.list_default;
- }
- if(bit15&0x80)
- func=0;
- }
- else if (c == CMD_SELECT)
- {
- //psprintf(linebuf,"psd_state=%02xn",psd_state);
- //epp_write_slow(linebuf);
- c = func&CMD_MASK;
- if (List.p.header!=LIST_SELECTION)
- {
- //#ifndef FUSS_DVD
- //terry,2002/5/10 10:38