📄 vcd.c
字号:
} } return (entry_number);}#ifdef ABSOLUTE_GOTO_TIME/*------------------------------------------------------------------------ Function:get_track_number Parameters: CDtime : BCD 0x00mmssff format. Description: Given a bcd time, return a track number that the CDtime is in that track. Return: 0 : NO good.------------------------------------------------------------------------*/int get_track_number(int cdtime){ int last_track; int found = 0; int cur_track_start, next_track_start; int i; unsigned int *scratch_buf; /* check if the time is too big */ if (cdtime >= (CDinfo.leadout & x00ffffff)) return 0; last_track = CDinfo.lasttrack; scratch_buf = (uint *)dram(TRACK_INFO_OFFSET); /* find the track */ i = CDinfo.firsttrack; cur_track_start = scratch_buf[i] & x00ffffff; i++; /* next track */ for ( ; i <= last_track; i++) { next_track_start = scratch_buf[i] & x00ffffff; if ((cdtime >= cur_track_start) && (cdtime < next_track_start)) { i--; /* previous track */ found = 1; break; } cur_track_start = next_track_start; } if (!found) i = (int)CDinfo.lasttrack; return (i);}#endif/*----------------------------------------------------------- Function: get_track_info Return Value: GOOD -> success BAD -> failure-----------------------------------------------------------*/int get_track_info(unsigned char track_num, unsigned int *start_mmssff, unsigned int *end_mmssff, unsigned char *type){#if 1 int addr, last_track; unsigned char *scratch_buf; last_track = CDinfo.lasttrack; if ((track_num < CDinfo.firsttrack) || (track_num > last_track)) return (BAD); /* get the track info data */ addr = track_num * 4 + dram_cached(TRACK_INFO_OFFSET); scratch_buf = (char *)(addr); *start_mmssff = (*((unsigned int *)&scratch_buf[0])) & x00ffffff; if (track_num < last_track) { *end_mmssff = (*((unsigned int *)&scratch_buf[4])) & x00ffffff; } else { /* it is the last track, so the end_mmssff is the leave out time */ *end_mmssff = CDinfo.leadout & x00ffffff; } *end_mmssff = adjCDtime(*end_mmssff, 0x0100, 0); /* minus 1 second */ *type = (scratch_buf[0] & 0x40) >> 6; /* check bit 6 for audio or data */ /* 0 -> CDDA. */ return (GOOD);#else /* get track info from entries.vcd */ /* get track info from entries.vcd */ int addr; int last_entry; int i, j; int find_first = 0; unsigned char *scratch_buf; /* check whether the seg_num is a good one */ *start_mmssff = 0x2933;track_num++; if (track_num < 2 || track_num > 99) return (BAD); addr = dram_cached(ENTRY_START_OFFSET); /* 0 base */ last_entry = get_total_entry_number(); for (i = 0; i < last_entry; i++) { if (!(mod_func(i, 64))) /* get next 64 long word bytes */ { addr = ENTRY_START_OFFSET + i * 4; /* 4 bytes per entry */ scratch_buf = (char *)(addr); } j = mod_func(i, 64); /* find the offset from scratch_buf */ /* check we find the first entry whose track number == track_num */ if ((scratch_buf[4*j] == track_num) && (!find_first)) { *start_mmssff = (*((unsigned int *)&scratch_buf[4*j])) & x00ffffff; find_first = 1; } /* check we find the first entry of the next track */ if ((scratch_buf[4*j] != track_num) && (find_first)) { *end_mmssff = (*((unsigned int *)&scratch_buf[4*j])) & x00ffffff; break; } } return (GOOD);#endif}/*----------------------------------------------------------- Function: reset_PSD NOTE: This function should be called when a new disk is put in CD drive.-----------------------------------------------------------*/void reset_PSD(){ PSD_start_addr = -1; PSD_end_addr = -1;}/*----------------------------------------------------------- Function: get_PSD Description: For a given PSD offset, it copys data from the PSD offset to buffer. Return Value: The number of bytes copied.-----------------------------------------------------------*/#define SECTION_SIZE 512 /* bytes */char * get_PSD(int offset, int size){ int addr; int sector; int start_mmssff, search_mmssff; unsigned char ss, ff, search_ff, search_ss; int tmp; int end_addr; addr = offset * 8; /* Offset multiplier */ end_addr = addr + size; if ((addr < PSD_start_addr || addr >= PSD_end_addr) || (end_addr >= PSD_end_addr)) { int num_of_sectors, i; int start_section; /* 512 bytes is one section. */ int start_offset; int end_section; /* We get one sector for PSD if all data we need belong to one sector. Otherwise, we need cross two secotrs.*/ start_section = (addr % PSD_SECTOR_SIZE) / SECTION_SIZE; end_section = (end_addr % PSD_SECTOR_SIZE) / SECTION_SIZE; /* byte position from 0 to 511 is section 1. byte position form 512 to 1023 is section 2.... */ if (start_section == 3) { /* the last section of the first sector and the first section of the next one. */ num_of_sectors = 2; } else { num_of_sectors = 1; } sector = addr / PSD_SECTOR_SIZE; start_offset = start_section * SECTION_SIZE; PSD_start_addr = sector * PSD_SECTOR_SIZE + (start_section * SECTION_SIZE); PSD_end_addr = PSD_start_addr + PSD_SIZE; for (i = 0; i < num_of_sectors; i++) { int offset; sector += i; tmp = (34 + sector) % 75; ff = hex2bcd[tmp]; /* 75 sector / second */ tmp = (34 + sector) / 75; ss = hex2bcd[tmp + 0x04]; search_mmssff = (ss << 8) | ff; getSectors(search_mmssff, 1, 2048); if (num_of_sectors == 1) { sram_to_dram(PSD_START_OFFSET, (int *)(CDI_ptr + start_offset), SECTION_SIZE * 2/4); } else { /* two sectors case */ if (i == 0) { sram_to_dram(PSD_START_OFFSET, (int *)(CDI_ptr + start_offset), SECTION_SIZE/4); } else { sram_to_dram((PSD_START_OFFSET + SECTION_SIZE/4), (int *)CDI_ptr, SECTION_SIZE/4); } } } } addr -= PSD_start_addr; /* adjust the addr */ return (char *)(addr + dram_cached(PSD_START_OFFSET));}#ifdef PLAY20/*----------------------------------------------------------- Function: VCD_pic_height_info() Description: (For VCD2.0 discs only) Given a track number, it returns vertical size information for the track. Return Value: zero -> NTSC (240) non-zero -> PAL (288)-----------------------------------------------------------*/int VCD_pic_height_info(int track_number){ int map_index, track_index, mask; track_index = track_number-1; map_index = track_index>>3; mask = (int)ptrLshift[track_index & 0x7]; return (track_map[map_index] & mask);}#endif#ifdef PRE_EMPHASISint is_track_pre_emphasis(int track_num){ int addr; char control; unsigned char *scratch_buf; /* get the track info data */ addr = track_num * 4 + dram_cached(TRACK_INFO_OFFSET); scratch_buf = (char *)(addr); control = scratch_buf[0] >> 4; /* see red book for info */ control &= 0xd; if ((control == 0x1) || (control == 0x9)) return 1; return 0;}#endif /*PRE_EMPHASIS*/#ifdef SCENE/*----------------------------------------------------------- Function: get_list_offset Description: For a given list ID number, it gets the the corresponding list ID offset. NOTE: (1) make sure list_id_num is within range. (2) only call this function after ABV/VBV activity has stopped,i.e. after system_reset(). Return Value: The list ID offset.-----------------------------------------------------------*/unsigned short get_list_offset(unsigned int list_id_num){ unsigned int sector, list_offset_position; unsigned short *list_offset_ptr; /* sector location of list_id_num */ sector = list_id_num>>10; /* Word position within sector */ list_offset_position = (list_id_num & 0x3ff); sector = adjCDtime(0x402, sector, 1); getSectors(sector, 1, 2048); /* data to VBV */ list_offset_ptr = (unsigned short *)dram_cached(VBV_start); list_offset_ptr += list_offset_position; return(*list_offset_ptr);}#endif /*SCENE*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -