📄 vcd_con.cpp
字号:
min_tno = com_bcdtobin(g_toc_info.tno[1].tno);
max_tno = cd_max_tno;
if (tno <= min_tno)
{
tno = max_tno;
}
else
{
if (prev)
{
--tno;
}
}
break;
case REPEAT_OFF: /* REPEAT OFF */
min_tno = com_bcdtobin(g_toc_info.tno[1].tno);
if ( (tno <= min_tno) && (prev == PREV_TRACK) )
{
tno = 0x0FF; /* STOP */
return (tno);
}
else
{
if (prev)
{
--tno;
}
}
break;
}
break;
case PMODE_RANDOM:
switch (g_repeat_mode)
{
case REPEAT_TT: /* REPEAT 1 */
tno = g_track;
break;
case REPEAT_ALL: /* REPEAT ALL */
g_pg_play_point--;
if (g_pg_play_point == 0xFF)
{
tno = (UBYTE) g_pg_entry[0];
g_pg_play_point = 0;
}
else
{
if (prev)
{
tno = (UBYTE) g_pg_entry[g_pg_play_point];
}
else
{
g_pg_play_point++;
tno = (UBYTE) g_pg_entry[g_pg_play_point];
}
}
break;
case REPEAT_OFF: /* REPEAT OFF */
g_pg_play_point--;
if ((g_pg_play_point == 0xFF) && (prev != CUR_TRACK))
{
tno = 0x0FF; /* STOP */
return (tno);
}
else
{
if (prev)
{
tno = (UBYTE) g_pg_entry[g_pg_play_point];
}
else
{
g_pg_play_point++;
tno = (UBYTE) g_pg_entry[g_pg_play_point];
}
}
break;
}
break;
default:
break;
}
/* error checks */
if (tno < 2)
tno = 0xff;
return (tno);
}
/*************************************************
Function Name: com_random_get
Purpose: Get a random number for shuffle play
Theory: Get a random number to be used as a
track number for shuffle play.
Arguments: maximum track number
Returns: track number
*************************************************/
UBYTE com_random_get(UBYTE max_num)
{
srand( OS_GetTicks() );
return ((UBYTE)(rand() % max_num) + 1);
}
/*************************************************
Function Name: com_suffle_get
Purpose: Build a play table for shuffle play.
Theory: Get a series of non-repeating random numbers
to be used as a play table for shuffle play.
Arguments: maximum track number, play table pointer
Returns: nothing
*************************************************/
void com_shuffle_get(UBYTE max_num, USHORT* buf)
{
UBYTE i, t;
for (i = 0; i < max_num; ++i)
{
while (1)
{
buf[i] = com_random_get(max_num);
if (i == 0)
{
break;
}
for (t = 0; t < i; ++t)
{
if (buf[t] == buf[i])
{
break;
}
}
if (t == i)
{
break;
}
}
}
}
/*************************************************
Function Name: update_timedisp_vcd
Purpose: Format the time display values.
Theory: To show the proper values on the time
display bar, they must be calculated
based on display mode, and then filtered
based on the position of the disc to
avoid any garbage on screen.
Arguments: none
Returns: nothing
*************************************************/
void update_timedisp_vcd(void)
{
ULONG temp, temp2, stime, etime, ctime, total_nr_seconds;
UBYTE cur_time[2], max[3], track_start[3], track_end[3], loc_ok, hold;
loc_ok = 0;
max[0] = (UBYTE)((g_max_time & 0xFF0000) >> 16);
max[1] = (UBYTE)((g_max_time & 0xFF00) >> 8);
max[2] = (UBYTE)(g_max_time & 0xFF);
com_tno_time_get(com_bintobcd(g_track), track_start, track_end);
stime = com_tno_time_bcdtobin(&track_start[0]);
etime = com_tno_time_bcdtobin(&track_end[0]);
ctime = com_tno_time_bcdtobin(&pbc_play_time[1]);
if (cd_max_tno != cd_max_tno_cdda)
{
if (g_track == cd_max_tno_cdda)
{
etime -= 375;
com_tno_time_bintobcd(etime, &track_end[0]);
}
}
if ((stime < ctime) && (etime > ctime))
{
loc_ok = 1;
}
/* legacy time calculation */
switch (time_info->display_mode)
{
default:
case CHAP_UP:
cur_time[0] = com_bcdtobin(g_time[0]);
cur_time[1] = com_bcdtobin(g_time[1]);
break;
case CHAP_DOWN:
temp = msf_sector_length(track_start, track_end);
if ((temp % 75) > 37)
temp = (temp / 75) + 1;
else
temp = temp / 75;
temp2 = (com_bcdtobin(g_time[0]) * 60) + com_bcdtobin(g_time[1]);
temp -= temp2;
cur_time[0] = (UBYTE)(temp / 60);
cur_time[1] = (UBYTE)(temp - (cur_time[0] * 60));
break;
case TITLE_UP:
if (g_pbc_on == PBC_ON)
hold = 0;
else
hold = 1;
temp2 = com_tno_time_bcdtobin(&g_toc_info.tno[hold].tim[0]);
temp = ctime;
temp = temp - temp2;
if ((temp % 75) > 37)
temp = (temp / 75) + 1;
else
temp = temp / 75;
cur_time[0] = (UBYTE)(temp / 60);
cur_time[1] = (UBYTE)((temp - (cur_time[0] * 60)));
break;
case TITLE_DOWN:
temp = msf_sector_length(&pbc_play_time[1], max);
if ((temp % 75) > 37)
temp = (temp / 75) + 1;
else
temp = temp / 75;
cur_time[0] = (UBYTE)(temp / 60);
cur_time[1] = (UBYTE)(temp - (cur_time[0] * 60));
break;
}
if (pbc_mode == PBC_MODE_LOAD)
{
time_info->hour = 0;
time_info->min = 0;
time_info->sec = 0;
loc_ok = 1;
}
else if (pbc_mode == PBC_MODE_STOP)
{
if (VERSION_FLG > 1)
{
time_info->hour = (com_bcdtobin( (UBYTE)((g_max_time & 0xFF0000) >> 16) )) / 120;
time_info->min = ((com_bcdtobin( (UBYTE)((g_max_time & 0xFF0000) >> 16) )) % 120) / 2;
time_info->sec = com_bcdtobin( (UBYTE)((g_max_time & 0xFF00) >> 8) ) / 2;
if((com_bcdtobin( (UBYTE)((g_max_time & 0xFF0000) >> 16) )) % 2)
time_info->sec += 30;
}
else
{
time_info->hour = (com_bcdtobin( (UBYTE)((g_max_time & 0xFF0000) >> 16) )) / 60;
time_info->min = (com_bcdtobin( (UBYTE)((g_max_time & 0xFF0000) >> 16) )) % 60;
time_info->sec = com_bcdtobin( (UBYTE)((g_max_time & 0xFF00) >> 8) );
}
loc_ok = 1;
}
else
{
if (VERSION_FLG > 1)
{
total_nr_seconds = (((cur_time[0] * 60) + (cur_time[1])) / 2); /* we divide by two compensate for drive speed */
time_info->hour = (UBYTE)(total_nr_seconds / 3600);
time_info->min = (UBYTE)((total_nr_seconds - (time_info->hour * 3600)) / 60);
time_info->sec = (UBYTE)(total_nr_seconds - (time_info->hour * 3600) - (time_info->min * 60));
}
else
{
time_info->hour = cur_time[0] / 60;
time_info->min = cur_time[0] % 60;
time_info->sec = cur_time[1];
}
}
temp = com_bcdtobin(g_info_vcd.album_seq[1]) + (com_bcdtobin(g_info_vcd.album_seq[0]) * 10);
time_info->title_n = (UBYTE) temp;
temp = com_bcdtobin(g_info_vcd.album_vol[1]) + (com_bcdtobin(g_info_vcd.album_vol[0]) * 10);
time_info->title_tot = (UBYTE) temp;
time_info->chap_tot = get_max_number_track();
if (g_track != g_track_prev)
{
if (g_track == 0xFF)
{
if (pbc_mode == PBC_MODE_STOP)
{
time_info->chap_n = get_max_number_track();
}
else
{
time_info->chap_n = 0;
}
}
else
{
time_info->chap_n = g_track - 1;
}
}
if ((g_play_kind == PKIND_PAUSE)&&(cdda_track))
{
loc_ok = 0;
}
if (loc_ok)
{
g_track_prev = g_track;
}
}
/*************************************************
Function Name: timesearch_valid
Purpose: Check the goto time input.
Theory: When a goto time command is recieved,
the input must be checked to see what track
it is in.
Arguments: input address
Returns: track number input is in, 0 if invalid
*************************************************/
UBYTE timesearch_valid(BOOLEAN fAbsolute, UBYTE *start)
{
UBYTE ret, track_start, new_track;
ULONG stime, etime, rtime;
DBGPRINT(DBG_ON(DBG_TRACE), ("timesearch_valid: Check the goto time input\n"));
ret = 0;
if (fAbsolute)
{
track_start = 2;
for (new_track = track_start; new_track < (cd_max_tno + 1); new_track++)
{
com_tno_time_get(com_bintobcd(new_track), &s_msf[0], &e_msf[0]);
if ((combine_msf(&start[0]) >= combine_msf(&s_msf[0])) &&
(combine_msf(&start[0]) < combine_msf(&e_msf[0])))
{
ret = new_track;
break;
}
}
}
else
{
if ((g_pbc_on == PBC_ON) && (g_track == 1))
{
stime = com_tno_time_bcdtobin(&s_msf[0]);
etime = com_tno_time_bcdtobin(&e_msf[0]);
rtime = com_tno_time_bcdtobin(&start[0]);
}
else
{
com_tno_time_get(com_bintobcd(g_track), &s_msf[0], &e_msf[0]);
stime = com_tno_time_bcdtobin(&s_msf[0]);
etime = com_tno_time_bcdtobin(&e_msf[0]);
rtime = com_tno_time_bcdtobin(&start[0]);
}
if ((stime + rtime) < (etime - 35))
{
com_tno_time_bintobcd((stime + rtime), &start[0]);
ret = g_track;
}
if (pbc_end_flag)
{
ret = 0;
}
}
return (ret);
}
/*************************************************
Function Name: load_tracks_svd
Purpose: Load the TRACKS.SVD file.
Theory: SVCD's have an extra information
file called the TRACKS.SVD that
needs to be loaded and parsed.
Arguments: none
Returns: error
*************************************************/
UBYTE load_tracks_svd(void)
{
UBYTE error = 0;
LOADER_FILE_HANDLE TracksFile = 0;
UBYTE ubData[2048];
if (LoaderFileOpen(tLoader, "/mnt/cdrom/svcd/tracks.svd", &TracksFile) != LOADER_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("load_tracks_svd: Failed file open!\n"));
TracksFile = 0;
error = 0xff;
goto errout;
}
if (LoaderFileRead(tLoader, TracksFile, (PVOID)ubData, 2048, NULL) == LOADER_SUCCESS)
{
ULONG offset = 0;
memcpy(g_tracks_svd.str, (BYTE *)(&ubData[offset]), 8);
offset += 8;
g_tracks_svd.ver = MAKE_WORD( (BYTE *)(&ubData[offset]) );
offset += 2;
g_tracks_svd.num_tracks = ubData[offset];
offset += 1;
DBGPRINT(DBG_ON(DBG_TRACE), ("g_tracks_svd.str = %s\n", g_tracks_svd.str));
DBGPRINT(DBG_ON(DBG_TRACE), ("g_tracks_svd.ver = 0x%X\n", g_tracks_svd.ver));
DBGPRINT(DBG_ON(DBG_TRACE), ("g_tracks_svd.num_tracks = %i\n", g_tracks_svd.num_tracks));
memcpy(g_tracks_svd.tracks, (BYTE *)(&ubData[offset]), g_tracks_svd.num_tracks * sizeof(SVCD_TRACK_INFO));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -