📄 discinfo.c
字号:
if ((_dStartAddr == 0) && (_bTotalSen == 0x01) && (!_bEmptyFlag)) // First Session
{
_bFirstTNo = 0;
_bEmptyFlag = TRUE;
goto lbDVDLeadInRetry;
}
}
#endif
lbDVDContinue :
// End sector number of data area
bHiByte(wHiWord(_dMaxLBA)) = 0x00;
bLoByte(wHiWord(_dMaxLBA)) = bReadDRAML(0, wBAddr + 12 + 9);
bHiByte(wLoWord(_dMaxLBA)) = bReadDRAML(0, wBAddr + 12 + 10);
bLoByte(wLoWord(_dMaxLBA)) = bReadDRAML(0, wBAddr + 12 + 11);
{
DWRD dwMaxLBA;
dwMaxLBA = _dMaxLBA - 0x30000;
vSetSharedInfo(SI_DDISC_MAX_LBA_B1, bLoByte(wLoWord(dwMaxLBA)));
vSetSharedInfo(SI_DDISC_MAX_LBA_B2, bHiByte(wLoWord(dwMaxLBA)));
vSetSharedInfo(SI_DDISC_MAX_LBA_B3, bLoByte(wHiWord(dwMaxLBA)));
vSetSharedInfo(SI_DDISC_MAX_LBA_B4, bHiByte(wHiWord(dwMaxLBA)));
}
#ifdef SUPPORT_DVDRAM_FAMILY
if (_fgDiskIsDVDRAM)
{
if (!fgInitDVDRAMDIT())
{
_bTotalSen = 0;
return (FALSE);
}
}
#endif
if (_bVRDiscFlag || _dMaxLBA == 0x30000)
{
_bVRDiscFlag = TRUE;
_dEndPSN0 = 0x300000;
_dMaxLBA = 0x300000;
}
else
{
/* Jacob: if the _dMaxLBA is 0, the reading procedure will be returned as
false, assign a ultimate value to fake the procedure. The current value
will be assigned later */
if (_dMaxLBA == 0) {
_dMaxLBA = 0x00300000;
}
_dEndPSN0 = _dMaxLBA;
}
if (_fgPTP)
{
if (_fgTwoLayer)
{
// Read Lead in data at layer1
_bSeekLayer = SEEK_LAYER1; // Read Lead in at layer 1
_dStartAddr = 0x2f200;
bCnt = 0;
if (_fgAbort)
{
goto lbDVDExitToc;
}
while (!fgReadLTData(AREA_LEADIN, 3))
{
if (_fgAbort)
{
goto lbDVDExitToc;
}
if (++bCnt == 4)
{
_bTotalSen = 0;
return (FALSE); // Invalid data of lead in area
}
_dStartAddr += 0x40;
}
DescrambleBlk(0, 12); // descramble Lead-in block
///////// layer1 ////////////////
// End sector number of Data Area for Layer 1
bHiByte(wHiWord(_dEndPSN1)) = 0x00;
bLoByte(wHiWord(_dEndPSN1)) = bReadDRAML(0, 12 + 9);
bHiByte(wLoWord(_dEndPSN1)) = bReadDRAML(0, 12 + 10);
bLoByte(wLoWord(_dEndPSN1)) = bReadDRAML(0, 12 + 11);
_dMaxLBA = _dEndPSN0 + _dEndPSN1 - 0x2ffff;
}
}
else // OTP
{
_dEndPSN1 = _dEndPSN0;
bHiByte(wHiWord(_dEndPSN0)) = 0;
bLoByte(wHiWord(_dEndPSN0)) = bReadDRAML(0, 12 + 13);
bHiByte(wLoWord(_dEndPSN0)) = bReadDRAML(0, 12 + 14);
bLoByte(wLoWord(_dEndPSN0)) = bReadDRAML(0, 12 + 15);
bHiByte(wHiWord(_dMaxLBA)) = 0xFF;
_dMaxLBA = _dEndPSN0 + _dEndPSN0 - (~_dMaxLBA) + 1;
}
#ifdef RS232_LOG_DVDTOC
DBGLogS("2.Max PSN (Layer 0):");
DBGLogB(0, bLoByte(wHiWord(_dMaxLBA)), bHiByte(wLoWord(_dMaxLBA)), bLoByte(wLoWord(_dMaxLBA)));
DBGLogS("\n");
#endif
_bFirstTNo = 1;
_bLastTNo = 1;
_fgHaveData = TRUE;
lbDVDExitToc:
return (!_fgAbort);
}
/***************************************************************************
Function : DIBuildDiscMap(void)
Dsecription : PROCEDURE : BUILD A DISC MAP OF TRACK DISTRIBUTION
Note : Builds a disc map which describes the distributions
of the audio and data tracks.
Disc Map Structure :
0: region type
1-3: LBA of end of region
4-7: LBA of start of region
8-11. Fixed packet length
Parameter : None
Return : None
***************************************************************************/
void DIBuildDiscMap(void)
{
WORD wIdx = 0;
BYTE bPrevTrkType;
DWRD idata dLBA, dPktSize;
WORD wTmp;
// _dXferBlkLen and _wStartXferID
// are used as temporary variables.
for (bHiByte(_wStartXferID)=1; bHiByte(_wStartXferID) <= _bTotalSen;
bHiByte(_wStartXferID)++)
{
// An Implied I-Trax Data Track is Considered for General Case!
if (bHiByte(_wStartXferID) == 1)
{
wTmp = 6;
bPrevTrkType = DATA_TRACK; // Always Says First Track is Data
_dXferBlkLen = 150; // first region start at physical LBA 150
}
else
{
bPrevTrkType = bReadTOCMem(wTmp+1) & 0x50;
dLBA = dMSFToLBA150(dReadTOCMem4(wTmp+2));
WriteDMMem(wIdx++, bLoByte(wHiWord(dLBA)));
WriteDMMem(wIdx++, bHiByte(wLoWord(dLBA)));
WriteDMMem(wIdx++, bLoByte(wLoWord(dLBA)));
WriteDMMem(wIdx++, 0);
WriteDMMem(wIdx++, bLoByte(wHiWord(_dXferBlkLen)));
WriteDMMem(wIdx++, bHiByte(wLoWord(_dXferBlkLen)));
WriteDMMem(wIdx++, bLoByte(wLoWord(_dXferBlkLen)));
WriteDMMem(wIdx++, 0); // lead-in/lead-out region
WriteDMMem(wIdx++, 0); // can't be written in fixed packets
WriteDMMem(wIdx++, 0); //
WriteDMMem(wIdx++, 0); //
if (bPrevTrkType == 0x50) // incrementally written track?
{ // yes, obtain packet length from TDB
if ((dPktSize = dDIGetPktLength(dLBA)) == 0)
{
bPrevTrkType = DATA_TRACK_VAR_PKT; // variable packet!
}
else
{
bPrevTrkType = DATA_TRACK_FIXED_PKT; // fixed packet!
}
}
else if (bPrevTrkType == 0x40)
{
bPrevTrkType = DATA_TRACK;
}
else
{
bPrevTrkType = AUDIO_TRACK;
}
wTmp += 6;
_dXferBlkLen = dLBA + 150; // start LBA of track
}
WriteDMMem(wIdx++, bPrevTrkType);
// Process All Normal Tracks in Session
while (bReadTOCMem(wTmp) < 100)
{
// get attributes of this track
bLoByte(_wStartXferID) = bReadTOCMem(++wTmp) & 0x50;
dLBA = dMSFToLBA150(dReadTOCMem4(++wTmp));
// A track of fixed packet must be recorded as a region in disc map.
if (bPrevTrkType == DATA_TRACK_FIXED_PKT)
{
WriteDMMem(wIdx++, bLoByte(wHiWord(dLBA))); // dLBA that concludes
WriteDMMem(wIdx++, bHiByte(wLoWord(dLBA))); // previous track
WriteDMMem(wIdx++, bLoByte(wLoWord(dLBA)));
WriteDMMem(wIdx++, 0); // start dLBA of prev. track
WriteDMMem(wIdx++, bLoByte(wHiWord(_dXferBlkLen)));
WriteDMMem(wIdx++, bHiByte(wLoWord(_dXferBlkLen)));
WriteDMMem(wIdx++, bLoByte(wLoWord(_dXferBlkLen)));
WriteDMMem(wIdx++, 0); // packet length
WriteDMMem(wIdx++, bLoByte(wHiWord(dPktSize)));
WriteDMMem(wIdx++, bHiByte(wLoWord(dPktSize)));
WriteDMMem(wIdx++, bLoByte(wLoWord(dPktSize)));
}
if (bLoByte(_wStartXferID) == 0x50) // incrementally written track?
{
if ((dPktSize = dDIGetPktLength(dLBA)) == 0)
{
bLoByte(_wStartXferID) = DATA_TRACK_VAR_PKT; // variable packet
}
else
{
bLoByte(_wStartXferID) = DATA_TRACK_FIXED_PKT; // fixed packet!
}
}
else if (bLoByte(_wStartXferID) == 0x40)
{
bLoByte(_wStartXferID) = DATA_TRACK;
}
else
{
bLoByte(_wStartXferID) = AUDIO_TRACK;
}
if (bPrevTrkType == DATA_TRACK_FIXED_PKT)
{
WriteDMMem(wIdx++, bLoByte(_wStartXferID)); // type of next region
_dXferBlkLen = dLBA + 150; // save track start LBA
}
else if (bPrevTrkType != bLoByte(_wStartXferID))// track type switch
{
WriteDMMem(wIdx++, bLoByte(wHiWord(dLBA))); // dLBA that concludes
WriteDMMem(wIdx++, bHiByte(wLoWord(dLBA))); // previous track
WriteDMMem(wIdx++, bLoByte(wLoWord(dLBA)));
WriteDMMem(wIdx++, 0); // start dLBA of prev. track
WriteDMMem(wIdx++, bLoByte(wHiWord(_dXferBlkLen)));
WriteDMMem(wIdx++, bHiByte(wLoWord(_dXferBlkLen)));
WriteDMMem(wIdx++, bLoByte(wLoWord(_dXferBlkLen)));
WriteDMMem(wIdx++, 0); // packet length
WriteDMMem(wIdx++, 0);
WriteDMMem(wIdx++, 0);
WriteDMMem(wIdx++, 0);
WriteDMMem(wIdx++, bLoByte(_wStartXferID)); // type of next region
_dXferBlkLen = dLBA + 150; // save track start LBA
}
bPrevTrkType = bLoByte(_wStartXferID);
wTmp += 4; // to A/C of the Next Track Record
}
// Point to Get Lead/Out MSF
wTmp += 2;
dLBA = dMSFToLBA(dReadTOCMem4(wTmp)); // LeadOut no miunus 150
// Check For UnClosed-Session Disc (Lead-Out May Be Reported As 0)
// Force Lead-Out Equal To Max Disc Size (100*60*75-2*75-1= 449849)
if (dLBA == 0)
{
dLBA = 449849;
}
WriteDMMem(wIdx++, bLoByte(wHiWord(dLBA)));
WriteDMMem(wIdx++, bHiByte(wLoWord(dLBA)));
WriteDMMem(wIdx++, bLoByte(wLoWord(dLBA)));
WriteDMMem(wIdx++, 0); // start dLBA of prev. track
WriteDMMem(wIdx++, bLoByte(wHiWord(_dXferBlkLen)));
WriteDMMem(wIdx++, bHiByte(wLoWord(_dXferBlkLen)));
WriteDMMem(wIdx++, bLoByte(wLoWord(_dXferBlkLen)));
WriteDMMem(wIdx++, 0); // packet length
WriteDMMem(wIdx++, bLoByte(wHiWord(dPktSize)));
WriteDMMem(wIdx++, bHiByte(wLoWord(dPktSize)));
WriteDMMem(wIdx++, bLoByte(wLoWord(dPktSize)));
_dXferBlkLen = dLBA; // lead-out LBA
WriteDMMem(wIdx++, LEADOUT_LEADIN); // LeadOut/LeadIn Region
wTmp += 4; // point to the first track of the next session
}
// Appends 0x00FFFFFF To Indicate End Of Map
if (wIdx == 0)
{
wIdx = 1; // prevent wIdx becomes to 0xFFFF
}
WriteDMMem(--wIdx, 0x00);
WriteDMMem(++wIdx, 0xFF);
WriteDMMem(++wIdx, 0xFF);
WriteDMMem(++wIdx, 0xFF);
vSetSharedInfo(SI_DDISC_MAX_LBA_B1, bHiByte(wHiWord(_dXferBlkLen)));
vSetSharedInfo(SI_DDISC_MAX_LBA_B2, bLoByte(wHiWord(_dXferBlkLen)));
vSetSharedInfo(SI_DDISC_MAX_LBA_B3, bHiByte(wLoWord(_dXferBlkLen)));
vSetSharedInfo(SI_DDISC_MAX_LBA_B4, bLoByte(wLoWord(_dXferBlkLen)));
// Store First Disc Map Entry (First 4 Bytes) in _dDiscMap.
// Note: DiscMap the byte order is inverted by real Disc Map
// _dDiscMap(bTrkType, bTrkEndH, bTrkEndM, bTrkEndL)
_dDiscMap = dReadDMMem4(0);
}
/***************************************************************************
Function : dDIGetPktLength(DWRD dLBA)
Dsecription : Read a TDB from the pre-gap of a incrementally written
track and return the packet length in binary.
Return 0 if the track is written in variable packets.
Return packet length if fixed packet.
Parameter : Address of TDB
Return : Packet Length
***************************************************************************/
DWRD dDIGetPktLength(DWRD dLBA)
{
WORD wTmp;
StopDecoder(); // Stop Decoding if Cache Miss
WriteDEC(RW_NSEC, 0x00); // Continuous Decoding// Aug 7
_fgDecErr = FALSE; // Clear to Make Sure Retry OK
dLBA = dLBAToMSF16(dLBA + 150 - 15); // org -9, address of TDB
WriteBIM(BIM_CFG, BCDEN + CDMODE);
WriteDEC(RW_TARR, 0x00);
WriteDEC(RW_TARH, bLoByte(wHiWord(dLBA)));
WriteDEC(RW_TARM, bHiByte(wLoWord(dLBA)));
WriteDEC(RW_TARL, bLoByte(wLoWord(dLBA)));
WriteBIM(BIM_CFG, CDMODE);
_bRDRetryCnt = 0;
do
{
//////////////////////// Status Checking Stage //////////////////////////
if (_fgAbort) // Abort Command !!
{
return (0); // failed to read TDB, assume variable packet size
}
////////////////////////// Error Handling Stage /////////////////////////
if (_testbit_(_fgDecErr))
{
if (++_bRDRetryCnt >= 5) // retry 5 times at most
{
return (0); // failed to read TDB, assume variable packet size
}
}
////////////////////////////// Seek Stage /////////////////////////////
if (!(bReadDEC(RW_TRIG) & (READTRG + DECTRG))) // decoder is off?
{
// Auto Mode & Form, Enable ECC
WriteDEC(RW_DCTRL0, ECCEN + QEN + PEN + MF_AUTO);
WriteDEC(RW_DCTRL1, RASEN + CD_RLIMIT); // Enable Auto Stop Buffering
WriteBLKC(RW_DBLK, 0); // Buffer TDB in block #0
WriteDEC(RW_BMT, CPDBLK); // BBLK = DBLK
// Enable Interrupt.
WriteDEC(RW_DIEN, DEIEN + MCIEN + RISCIEN);
// Enable Decoding Error Interrupt -- Add by Yih-Shin
WriteDEC(RW_DENEN, ADDREN + EDCEN);
_fgDecErr = FALSE;
SRVSetSpeed(LEADIN_CD_SPEED);
// Retrieve the READ target from TARH, TARM, and TARL.
WriteBIM(BIM_CFG, BCDEN + CDMODE);
bLoByte(wHiWord(dLBA)) = bReadDEC(RW_TARH);
bHiByte(wLoWord(dLBA)) = bReadDEC(RW_TARM);
bLoByte(wLoWord(dLBA)) = bReadDEC(RW_TARL);
WriteBIM(BIM_CFG, CDMODE);
dLBA = dMSFForSeek(dLBA);
MCDRdSeek2(bLoByte(wHiWord(dLBA)),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -