📄 dosusr.c
字号:
}
return sts;
}
//-----------------------------------------------------------------------------
//USR_DeleteFile
//-----------------------------------------------------------------------------
BYTE USR_DeleteFile(BYTE selectDir, WORD selectCount) USING_0
//BYTE USR_DeleteFile(BYTE selectDir, BYTE minorMode, WORD selectCount) USING_0 //@@chchang_012203
{
BYTE sts, dirIndex;
BYTE filereq;
//DbgPrint("selectDir %bx\n",selectDir);
if ((sts = dirIndex = USR_SetDir1(selectDir))!=0xff) //@@chchang_012203
{
#if 0
if (selectDir != K_USR_MP3_DIR)
{
filereq=USR_GetFileType(dirIndex);
sts = USR_InitFileCount(&G_USR_DirList[dirIndex].totalFile,filereq);
if (sts)
{
BYTE name[12];
USR_SetWaveName(name, G_USR_DirList[dirIndex].lastFileIndex);
sts = File_Delete(name);
}
}
else
#endif
{
ULONG fdbLogAddr;
WORD fdbOffset;
filereq=USR_GetFileType(dirIndex);
sts = USR_FindCountedFile(selectCount, &fdbLogAddr, &fdbOffset,filereq);
if (sts)
{
sts = DOS_DeleteFile(G_ucStorData, fdbOffset, fdbLogAddr);
}
}
}
if (sts && G_USR_DirList[dirIndex].totalFile > 0)
{
G_USR_DirList[dirIndex].totalFile -= 1;
//DbgPrint("totalFile %d\n", G_USR_DirList[dirIndex].totalFile);
}
return sts;
}
//-----------------------------------------------------------------------------
//USR_DeleteAllFile
//-----------------------------------------------------------------------------
/* SGJM TEMP DEL
BYTE USR_DeleteAllFile(BYTE selectDir, BYTE fileType) USING_0
//BYTE USR_DeleteAllFile(BYTE selectDir, BYTE minorMode, BYTE fileType) USING_0 //@@chchang_012203
{
BYTE sts, dirIndex;
BYTE filereq;
if ((sts = dirIndex = USR_SetDir1(selectDir))!=0xff) //@@chchang_012203
{
File_DeleteAllFile(K_USR_MatchFileType, fileType);
filereq=USR_GetFileType(dirIndex); //chchang_01/10/2003
sts = USR_InitFileCount(&G_USR_DirList[dirIndex].totalFile,filereq);
}
return sts;
}
*///-----------------------------------------------------------------------------
//File_SendMessage: for digital camera
//-----------------------------------------------------------------------------
ULONG File_SendMessage( USHORT message, ULONG param ) USING_0
{
ULONG ulTemp = param;
ULONG result = 0;
switch ( message )
{
case K_File_UI_Start_DscFile:
break;
case K_File_UI_Start_DscImage:
break;
case K_File_UI_End_DscImage:
break;
case K_File_UI_Start_VideoImage: // 500 use
break;
case K_File_UI_End_VideoImage: // 500 use
break;
case K_File_UI_End_DscFile:
break;
case K_File_UI_Err_DscFile:
break;
case K_File_UI_Start_AviFile:
break;
case K_File_UI_End_AviFile:
break;
case K_File_UI_Err_AviFile:
break;
case K_File_UI_Periodical:
break;
case K_File_UI_VideoStrm1Frame:
break;
case K_File_UI_Error:
break;
case K_File_UI_Start_WaveFile:
break;
case K_File_UI_End_WaveFile:
break;
case K_File_UI_Err_WaveFile:
break;
} // end switch
return result;
}
//**************************
//*Chchang Plus
//**************************
/*--------------------------------------------------------------------------
dump data from 1k sram to check data
----------------------------------------------------------------------------*/
#if 1
/* SGJM TEMP DELETE void dump_G_ucStorData(void)
{
WORD i,j;
if(G_DOS_ReadToFatSector)
{
DbgPrint("G_ucStorDataFAT[]");
}
else
{
DbgPrint("G_ucStorData[]");
}
DbgPrint("------------------------------------------------------------");
for(i=0;i<0x20;i++){
DbgPrint("\n\r%3bx:",(UCHAR)i*0x10);
if(G_DOS_ReadToFatSector)
{
for(j=0;j<0x10;j++) DbgPrint("%2bx ",(UCHAR)G_ucStoreFAT[i*0x10+j]);
}
else
{
for(j=0;j<0x10;j++) DbgPrint("%2bx ",(UCHAR)G_ucStorData[i*0x10+j]);
}
DbgPrint(" ");
}
DbgPrint("\n\r");
}*/
#endif
//----------------------------------------------------------------------//
//=====================
//check *.wav headfile
//=====================
code UCHAR WaveChkPosition[] ={
0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B,
0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13,
0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B,
0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23,
0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B,
0x2C, 0x2D, 0x2E, 0x2F, 0x34, 0x35, 0x36, 0x37
};
code UCHAR SunplusWavHead[] ={
0x52, 0x49, 0x46, 0x46, 0x57, 0x41, 0x56, 0x45,
0x66, 0x6D, 0x74, 0x20, 0x14, 0x00, 0x00, 0x00,
0x11, 0x00, 0x01, 0x00, 0x40, 0x1F, 0x00, 0x00,
0xD7, 0x0F, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00,
0x02, 0x00, 0xF9, 0x01, 0x66, 0x61, 0x63, 0x74,
0x04, 0x00, 0x00, 0x00, 0x64, 0x61, 0x74, 0x61
};
/*----------------------------------------------------------------------------
check the head file of ADPCM
------------------------------------------------------------------------------*/
BYTE USR_Check_DVR_Head(WORD StartCluster) USING_0
{
ULONG DATA_LogAddr;
BYTE sts;//PLAY,End_of_File;
BYTE i;
i=0;
// PLAY=0;
// End_of_File=1;
DATA_LogAddr = DOS_ClusterLogAddr(StartCluster);
sts = DOS_ReadSector(K_DOS_SrcSram, DATA_LogAddr,0); //dump the first data sector
while(sts)
{
sts=(G_ucStorData[WaveChkPosition[i]]==SunplusWavHead[i]);
if(sts==0) return 1;//End_of_File;
i+=1;
if(i==48) return 0;//PLAY;
}
// return End_of_File;
}
/*---------------------------------------------------------------------------
close the RECORD file and add the ADPCM head file
-----------------------------------------------------------------------------*/
void USR_File_Close(/*UCHAR MinorMODE*/ULONG fileSize,BYTE *name) USING_0
{
BYTE sts;
BYTE fileSts;
ULONG DATA_LogAddr;
ULONG audioSize;
U32DATA NewBlockNum;
sts = fileSts = File_Close(1, name, K_DOS_NewFile, fileSize);
//==============
//initial value
//==============
DATA_LogAddr=0;
audioSize=0;
// ADPCM turn on this and AudioDSP_EncoderBitStream use KDVR_ADPCM_4bit mode
if(_G723==FALSE)
{
//ULONG DATA_LogAddr;
//U32DATA NewBlockNum;
//ULONG audioSize;
//ADPCM
//read the first sector of file and update wave file header
DATA_LogAddr = DOS_ClusterLogAddr(G_DOS_StartClusterNumber);
sts = DOS_ReadSector(K_DOS_DstSram, DATA_LogAddr, 0);
audioSize = fileSize - 0x3c;// minus header size 3c
NewBlockNum.dwData = audioSize; //0xFFFFFFFFF
G_ucStorData[0x38] = NewBlockNum.BYTEData[3];
G_ucStorData[0x39] = NewBlockNum.BYTEData[2];
G_ucStorData[0x3A] = NewBlockNum.BYTEData[1];
G_ucStorData[0x3B] = NewBlockNum.BYTEData[0];
audioSize += 0x34;
NewBlockNum.dwData = audioSize; //0xFFFFFFFFF
G_ucStorData[0x04] = NewBlockNum.BYTEData[3];
G_ucStorData[0x05] = NewBlockNum.BYTEData[2];
G_ucStorData[0x06] = NewBlockNum.BYTEData[1];
G_ucStorData[0x07] = NewBlockNum.BYTEData[0];
// sample rate is 8000, when block is 256,then 505, when block is 512 then 1017
G_ucStorData[0x30] = (BYTE)505;
G_ucStorData[0x31] = (BYTE)(505>>8);
G_ucStorData[0x32] = (BYTE)8000;
G_ucStorData[0x33] = (BYTE)(8000>>8);
// average byte per second
// sample rate is 8000, when block is 256,then 4055, when block is 512 then 4028
G_ucStorData[0x1c] = (BYTE)4055;
G_ucStorData[0x1d] = (BYTE)(4055>>8);
G_ucStorData[0x1e] = (BYTE)(4055>>16);
G_ucStorData[0x1f] = (BYTE)(4055>>24);
sts = DOS_WriteSector(K_DOS_SrcSram, DATA_LogAddr, 0);
// dump_G_ucStorData();
}
else if(_G723==TRUE)
{//@@chchang_010303
//ULONG DATA_LogAddr;
//ULONG audioSize=0;
//U32DATA NewBlockNum;
ULONG Data_Packet_count;
Data_Packet_count=0;
//read the first sector of file and update wave file header
DATA_LogAddr = DOS_ClusterLogAddr(G_DOS_StartClusterNumber);
sts = DOS_ReadSector(K_DOS_DstSram, DATA_LogAddr, 0);
//G723_ASF_filesize
audioSize = fileSize;// minus header size 3c
NewBlockNum.dwData = audioSize; //0xFFFFFFFF
// 0 1 2 3
G_ucStorData[0x46] = NewBlockNum.BYTEData[3];
G_ucStorData[0x47] = NewBlockNum.BYTEData[2];
G_ucStorData[0x48] = NewBlockNum.BYTEData[1];
G_ucStorData[0x49] = NewBlockNum.BYTEData[0];
//G723_ASF_Data_Packet_Count
Data_Packet_count = ((audioSize>>9)<<1)-2; //(audiosize/512)*2
NewBlockNum.dwData = Data_Packet_count; //0xFFFFFFFF
//header object // 0 1 2 3
G_ucStorData[0x56] = NewBlockNum.BYTEData[3];
G_ucStorData[0x57] = NewBlockNum.BYTEData[2];
G_ucStorData[0x58] = NewBlockNum.BYTEData[1];
G_ucStorData[0x59] = NewBlockNum.BYTEData[0];
//data object
G_ucStorData[0x01f6] = NewBlockNum.BYTEData[3];
G_ucStorData[0x01f7] = NewBlockNum.BYTEData[2];
G_ucStorData[0x01f8] = NewBlockNum.BYTEData[1];
G_ucStorData[0x01f9] = NewBlockNum.BYTEData[0];
//=================================================================================
//G723_ASF_PlayDuration/SendDuration(this must be correct otherwise will not play)
//=================================================================================
//play duration
NewBlockNum.dwData = L2_DSP_Multi_CMD_Get(Data_Packet_count,0,0);
G_ucStorData[0x5E] = NewBlockNum.BYTEData[3]; //low 24bits
G_ucStorData[0x5F] = NewBlockNum.BYTEData[2];
G_ucStorData[0x60] = NewBlockNum.BYTEData[1];
NewBlockNum.dwData = L2_DSP_Multi_CMD_Get(Data_Packet_count,1,0);
G_ucStorData[0x61] = NewBlockNum.BYTEData[3]; //high 24bits
G_ucStorData[0x62] = NewBlockNum.BYTEData[2];
G_ucStorData[0x63] = NewBlockNum.BYTEData[1];
//send duration
NewBlockNum.dwData = L2_DSP_Multi_CMD_Get(Data_Packet_count,0,1);
G_ucStorData[0x66] = NewBlockNum.BYTEData[3]; //low 24bits
G_ucStorData[0x67] = NewBlockNum.BYTEData[2];
G_ucStorData[0x68] = NewBlockNum.BYTEData[1];
NewBlockNum.dwData = L2_DSP_Multi_CMD_Get(Data_Packet_count,1,1);
G_ucStorData[0x69] = NewBlockNum.BYTEData[3]; //high 24bits
G_ucStorData[0x6A] = NewBlockNum.BYTEData[2];
G_ucStorData[0x6B] = NewBlockNum.BYTEData[1];
//Data object size
audioSize = fileSize-0x1CE;
NewBlockNum.dwData = audioSize;
G_ucStorData[0x1DE] = NewBlockNum.BYTEData[3];
G_ucStorData[0x1DF] = NewBlockNum.BYTEData[2];
G_ucStorData[0x1E0] = NewBlockNum.BYTEData[1];
G_ucStorData[0x1E1] = NewBlockNum.BYTEData[0];
sts = DOS_WriteSector(K_DOS_SrcSram, DATA_LogAddr, 0);
}
if (fileSts)
{
BYTE selectDir;
//if (MinorMODE == KDVR_G723_5K)
//selectDir = K_USR_G723_DIR;
//else
selectDir = K_USR_ADPCM_DIR;
G_USR_DirList[selectDir].totalFile++;
}
}
/*===========================
search the correct cluster
chchang 12/31/2002
=============================*/
//given sectorIndex,get *pCurrCluster
USHORT USR_File_Seek(ULONG sectorIndex) USING_0
{
WORD searchCluster;
WORD clusterNum,i; //if flash over 128Mb must define ULONG
//if(sectorIndex >= G_total_sectorNUM)
//{
// DbgPrint("sectorIndex is over the G_total_sectorNUM\n");
// return FALSE;
//}
searchCluster = G_DOS_FileStartCluster;
clusterNum = sectorIndex/G_DOS_SectorPerCluster;
//notice: clusternum count error will make FAT chain search error
if((sectorIndex%G_DOS_SectorPerCluster)==0)
{
clusterNum = clusterNum-1; //chchang_1_03_2003
}
//@@
//start to search cluster
for(i=0;i<clusterNum;i++)
{
searchCluster = DOS_GetNextCluster(searchCluster);
}
//current sector's cluster
//G_searchCluster = searchCluster;
return searchCluster;
}
//chchang
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -