⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cd.c

📁 一个两碟控制的VCD的代码,两碟之间的转动及连续播放,已大量生产的CODE.
💻 C
字号:
/* Copyright 1996, ESS Technology, Inc.					*//* SCCSID @(#)cd.c	1.9 10/17/97 *//* * $Log$ */#include "cd.h"#include "const.h"#include "sysinfo.h"#include "util.h"#include "vcxi.h"#ifdef PLAY20/************************************************************************ * Utility routine to adjust the CD time.				* ************************************************************************//*------------------------------------------------------------------------  Description:      return (time - amount) / 9.      This function is used for track digest.  It should be rewritten      later.------------------------------------------------------------------------*/unsigned int deltaCDtime(unsigned int time, unsigned int amount){    int i;    int array[2], tmp;    if (amount > time) 	return(0);    time >>= 8;    amount >>= 8;    for (i = 0; i < 2; i++) {	/* Translate BCD bytes to HEX bytes */	array[i] = (int) bcd2hex[time & 0xff];	tmp = (int) bcd2hex[amount & 0xff];	array[i] -= tmp;	time >>= 8;	amount >>= 8;    }       tmp = array[0];    tmp += array[1] * 60;    tmp /= 9;    array[1] = tmp/60;    array[0] = tmp - array[1] * 60;    /* Translate back to BCD */    array[0] = (int) hex2bcd[array[0]];    array[1] = (int) hex2bcd[array[1]];    return((array[1] << 16) | (array[0] << 8) | 0);}/*  * Translate sector number into mm:ss:ff. Since division and mod are * rather expensive in MIPS-X, we'll use multiplication instead. * * Input:	num is the sector number * Return:	MMSSFF in CD time format where each of MM/SS/FF is a BCD */int logical2physical(int num){    int array[3];    array[2] = 0;    array[0] = num;    while (array[0] > 0) {	array[0] -= 4500;	/* 60 * 75 */	array[2]++;    }    if (array[0] != 0) {	array[2]--;	array[0] += 4500;    }    array[1] = 0;    while (array[0] > 0) {	array[0] -= 75;	array[1]++;    }    if (array[0] != 0) {	array[1]--;	array[0] += 75;    }    /* Translate from HEX to BCD */    array[0] = (int) hex2bcd[array[0]];    array[1] = (int) hex2bcd[array[1]];    array[2] = (int) hex2bcd[array[2]];    return((array[2] << 16) | (array[1] << 8) | array[0]);}#endif /* PLAY20 *//* * This routine operates on 2 CD-format time and return the result. * CD-format time is MMSSFF where each of MM/SS/FF is in BCD * * Inputs: *	time:		CD format time to be adjusted *	amount:		Amount to adjust with in CD format time *	direction:  	1: to add the two numbers together *		    other: time - amount * * Return: *	result:		in CD format time * * I assume the sum and difference are all within CD range. I.e. this * routine is defined to do fine grain adjustment arount a given time. */unsigned int adjCDtime(time, amount, direction)unsigned int time, amount, direction;{    int i;    int array[3], tmp;    if (direction != 1) {	/* Substraction may underflow, in which case, set the result to 0 */	if (amount > time) return(0);    }    for (i = 0; i < 3; i++) {	/* Translate BCD bytes to HEX bytes */	array[i] = (int) bcd2hex[time & 0xff];	tmp = (int) bcd2hex[amount & 0xff];	if (direction == 1) array[i] += tmp;	else		    array[i] -= tmp;	time >>= 8;	amount >>= 8;    }    /* Normalize into acceptable HEX ranges */    if (direction == 1) {	if (array[0] >= 75) {array[0] -= 75; array[1] += 1;}	if (array[1] >= 60) {array[1] -= 60; array[2] += 1;}	/* If time is overflowing, then set to 99:59:74 */	if (array[2] >= 99) {array[2]  = 99; array[1]  = 59; array[0] = 74;}    } else {	if (array[0] < 0) {array[0] += 75; array[1] -= 1;}	if (array[1] < 0) {array[1] += 60; array[2] -= 1;}    }    /* Translate back to BCD */    array[0] = (int) hex2bcd[array[0]];    array[1] = (int) hex2bcd[array[1]];    array[2] = (int) hex2bcd[array[2]];    return((array[2] << 16) | (array[1] << 8) | array[0]);}

⌨️ 快捷键说明

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