www.pudn.com > OS.rar > S320TTS_Data_Access_prefetch_byFAT.asm, change:2006-12-11,size:8742b


 
.include Snd_ArithmConfig.inc	// define compiler config const 
.include SACM_Constant.inc		// for flag / buffer constants 
 
.ifdef C_SND_S320TTS_SUPPORT 
//---------------------------------------------------------- 
 
.PUBLIC F_SACM_TTS320_System_Get_SAC_Manual 
.PUBLIC F_SACM_TTS320_System_Get_BS_Initial 
.PUBLIC F_SACM_TTS320_Decode_Initial_BS 
.PUBLIC F_SACM_TTS320_System_Get_BS_Manual 
.external T_SACM_CS0S320TTS_Table 
 
.ifdef FAT 
.external _S320TTS1BIN_Access_Init	//added by mgl 2005/04/20 for open SP_WORD.320 
.external _S320TTS1BIN_Access_GetData	//added by mgl 2005/04/20 for get SP_WORD.320 data 
.external _S320TTS1BIN_Access_End	//added by mgl 2005/04/20 for close SP_WORD.320 
.endif 
 
.EXTERNAL R_SACM_XXXX_Resouce_BS,	R_SACM_XXXX_Resouce_DS 
.EXTERNAL R_SACM_Resouce_BS,		R_SACM_Resouce_DS	//guili 2005.12.01 for S480 no Speed control 
.EXTERNAL R_SACM_XXXX_Decode_Length_L,	R_SACM_XXXX_Decode_Length_H 
.external R_SACM_Decode_Length_L,	R_SACM_Decode_Length_H	//guili 2005.12.01 for S480 no Speed control 
.EXTERNAL R_SACM_XXXX_Decode_Count_L,	R_SACM_XXXX_Decode_Count_H 
.external R_SACM_Decode_Count_L,	R_SACM_Decode_Count_H	//guili 2005.12.01 for S480 no Speed control 
.EXTERNAL R_SACM_XXXX_Decode_In_PTR,	R_SACM_XXXX_Decode_In_Buffer 
.external R_SACM_Decode_In_PTR,		R_SACM_Decode_In_Buffer	//guili 2005.12.01 for S480 no Speed control 
 
.PUBLIC R_DIC_Buffer,		R_DIC_PTR 
.PUBLIC R_START_ADDR_BUFFER,	R_ADDR_PTR 
.PUBLIC R_Syllable_Num 
 
.PUBLIC _TTS_Syllable_Num 
.PUBLIC _TTS1BIN_Curr_Addr,	_TTS1BIN_Curr_DS 
.PUBLIC _TTS1BIN_Dest_Addr,	_TTS1BIN_Dest_DS 
.PUBLIC _Frame_Length; 
 
.external _fs_Handle_S320TTS1 
 
.define MAX_SEG			20 
OVERLAP_TTS_DM_BLOCK:	.SECTION	.ORAM 
R_DIC_Buffer:		.DW	MAX_SEG DUP(?) 
R_START_ADDR_BUFFER:	.DW	MAX_SEG * 2 DUP(?) 
R_DIC_PTR:		.DW	? 
R_ADDR_PTR:		.DW	? 
R_Syllable_Num:		.DW	? 
_TTS_Syllable_Num:	.DW	3 
//not change this 4 var define order,because at another place,TTS1BIN_Dest_Addr is used as long 
.var _TTS1BIN_Curr_Addr,	_TTS1BIN_Curr_DS 
.var _TTS1BIN_Dest_Addr,	_TTS1BIN_Dest_DS 
//.var _TTS1BIN_Dest_Offset 
.var _Frame_Length 
 
.define C_EXTRAM_IN_LENGTH 	2000 
.define R_SACM_XXXX_ExtRam_In_Buffer_Low	0x0000	//mgl 2005/04/04 fix __sp_..._end=0x7d0 
.define R_SACM_XXXX_ExtRam_In_Buffer_High	0x0009 
 
.CODE 
//------------------------------------------------- 
//2005/03/29 
F_SACM_TTS320_System_Get_SAC_Manual: .PROC 
	push BP to [SP] 
	// DS:R4 = DS:BS 
	SR &= ~0xfc00 
	SR |= [R_SACM_XXXX_Resouce_DS] 		//2005/03/29 
	R4 = [R_SACM_XXXX_Resouce_BS] 		//2005/03/29 
	 
  	// R_Syllable_Num = R5 = DS:[R4] & 0xFF 
  	//R1 = DS:[R4]				//del by mgl 2005/04/05 
  	//R5 = R1 & 0xFF			//del by mgl 2005/04/05 
  	R5 = [_TTS_Syllable_Num] 
  	// if(R5>MAX_SEG) R5 = MAX_SEG; 
  	cmp R5, MAX_SEG 
  	jle ?_EndOfLimiter 
	R5 = MAX_SEG 
?_EndOfLimiter: 
  	[R_Syllable_Num] = R5 
 
	//Get Segment information 
	R1 = R_DIC_Buffer 
	[R_DIC_PTR] = R1 
	R1 = R_START_ADDR_BUFFER 
	[R_ADDR_PTR] = R1 
?_even: 
//?_odd: 
	// even ////////////////////////// 
	// if(SybCnt==0) break; 
	cmp R5, 0 
	jz ?_EndOfGetSeg 
	// SybCnt--; 
	R5 -= 1 
	// Address_Low 
	R3 = [R_ADDR_PTR] 
	R1 = DS:[R4++] 
	R2 = R1 LSL 2 
	[R3++] = R2 
	// Address_High 
	R2 = DS:[R4] 
	R2 &= 0x3 
	R1 = R1 LSL 4 
	R2 = R2 ROL 2 
	[R3++] = R2 
	[R_ADDR_PTR] = R3 
	// DataLength (= FrameLength * 4) 
	R3 = [R_DIC_PTR] 
	R1 = DS:[R4] 
	R1 &= 0xFC 
	[R3++] = R1 
	[R_DIC_PTR] = R3 
	 
//	jmp ?_odd 
	// odd ////////////////////////// 
	// if(SybCnt==0) break; 
	cmp R5, 0 
	jz ?_EndOfGetSeg 
	// SybCnt--; 
	R5 -= 1 
	// Address_Low 
	R3 = [R_ADDR_PTR] 
	R1 = DS:[R4++] 
	R2 = DS:[R4] 
	R1 = R1 LSL 4 
	R2 = R2 ROL 4 
	R1 = R1 LSL 4 
	R2 = R2 ROL 4 
	R2 = R2 LSL 2 
	[R3++] = R2 
	// Address_High 
	R1 = DS:[R4++] 
	R1 = R1 LSR 4 
	R1 = R1 LSR 2 
	R2 = R1 & 0x0F 
	[R3++] = R2 
	[R_ADDR_PTR] = R3 
	// DataLength (= FrameLength * 4) 
	R3 = [R_DIC_PTR] 
	R1 = R1 LSR 2 
	R1 &= 0xFC 
	[R3++] = R1 
	[R_DIC_PTR] = R3 
	jmp ?_even 
 
?_EndOfGetSeg: 
	R1 = R_DIC_Buffer 
	[R_DIC_PTR] = R1 
	R1 = R_START_ADDR_BUFFER 
	[R_ADDR_PTR] = R1 
	 
	pop BP from [SP] 
	retf; 
.endp 
 
//------------------------------------------------------------ 
F_SACM_TTS320_System_Get_BS_Initial: .proc 
	R1 = R_DIC_Buffer; 
	r4 = [r1++] 
	[_Frame_Length] = R4; 
	[R_DIC_PTR] = r1 
		 
	R1 = R_START_ADDR_BUFFER 
	R3 = [R1++];		//L 
	R2 = [R1++];		//H 
	[R_ADDR_PTR] = R1;	//second DIC start addr 
 
?_LengthToPage: 
// ========== begin ======================= 
	[_TTS1BIN_Curr_DS]=r2 
	[_TTS1BIN_Curr_Addr]=r3 
.ifdef FAT 
	call _S320TTS1BIN_Access_Init	//added by mgl for open SP_WORD.320 
.endif 
// ========== end ======================= 
	call F_S320TTS_System_Get_BS_ExtRam	//get all data of this word to buffer 
.ifdef FAT 
	call _S320TTS1BIN_Access_End		//added by mgl for close SP_WORD.320 
.endif 
	RETF; 
.endp 
 
//---------------------------------------------------------- 
F_SACM_TTS320_Decode_Initial_BS: .PROC 
	R1 = R_DIC_Buffer 
	R2 = R1 + [_TTS_Syllable_Num] 
	R3 = 0 
	cmp R1, R2 
	je ?_EndOfSum 
?_SumLoop: 
	R3 += [R1++] 
	cmp R1, R2 
	jne ?_SumLoop 
?_EndOfSum: 
	R4 = 0	 
 	[R_SACM_XXXX_Decode_Length_L] = R3 	//2005/03/31 
 	[R_SACM_XXXX_Decode_Length_H] = R4 	//2005/03/31 
	[R_SACM_XXXX_Decode_Count_L] = R4  	//2005/03/31 
	[R_SACM_XXXX_Decode_Count_H] = R4  	//2005/03/31 
 
	retf 
.ENDP 
 
//---------------------------------------------------------- 
F_SACM_TTS320_System_Get_BS_Manual: .proc 
	R1 = [R_SACM_XXXX_Decode_In_PTR]; 
	cmp R1, R_SACM_XXXX_Decode_In_Buffer; 
	jne ?_Continue_1; 
	goto ?_Branch_0; 
?_Continue_1: 
	cmp R1, R_SACM_XXXX_Decode_In_Buffer + C_DECODE_IN_LENGTH; 
	jl ?_Branch_1; 
		 
	R1 = R_SACM_XXXX_Decode_In_Buffer; 
	[R_SACM_XXXX_Decode_In_PTR] = R1; 
	jmp ?_Branch_2; 
		 
?_Branch_1: 
	R2 = R_SACM_XXXX_Decode_In_Buffer; 
	R3 = R_SACM_XXXX_Decode_In_Buffer + C_DECODE_IN_LENGTH; 
	 
?_Loop_0: 
	R4 = [R1++]; 
	[R2++] = R4; 
	cmp R1, R3; 
	jne ?_Loop_0; 
 
	[R_SACM_XXXX_Decode_In_PTR] = R2; 
 
?_Branch_2: 
	R1 = [R_SACM_XXXX_Decode_In_PTR]; 
	R2 = R_SACM_XXXX_Decode_In_Buffer + C_DECODE_IN_LENGTH; 
	R2 -= R1; 
	push r1,r2 to [sp] 
	 
 	call F_TTS320_GetData		//mgl 2005/03/15 
	// parameter: R1 = R_SACM_Decode_In_Buffer, 
	//            R2 = C_DECODE_IN_LENGTH   
	// return with R_SACM_Decode_In_Buffer filled 	  
 
	sp += 2 
	R1 = R_SACM_XXXX_Decode_In_Buffer; 
	[R_SACM_XXXX_Decode_In_PTR] = R1; 
	 
?_Branch_0:		 
 	retf; 
.endp 
 
//------------------------------------------------------------ 
// parameter: R1 = R_SACM_Decode_In_Buffer, 
//            R2 = C_DECODE_IN_LENGTH   
// return with R_SACM_Decode_In_Buffer filled 	  
.define DesPtr	0 
.define CopyLen	1 
F_TTS320_GetData:	.proc 
	push BP to [SP] 
	BP = SP + 4 
 
	r1 = [bp+DesPtr] 
	r2 = [bp+CopyLen] 
 
	R3 = [_TTS1BIN_Dest_Addr]; 
	R4 = [_TTS1BIN_Dest_DS];  
	DS = R4; 
?L_Get_Loop: 
	cmp R2, 0; 
	jz ?L_End; 
	R4 = DS:[R3++]; 
	[R1++] = R4; 
	R2 -= 1; 
	jmp ?L_Get_Loop; 
 
?L_End: 
	R4 = DS; 
	[_TTS1BIN_Dest_DS] = R4; 
	[_TTS1BIN_Dest_Addr] = R3; 
 
	pop bp from [sp] 
	retf; 
.endp 
 
//------------------------------------------------------------ 
F_S320TTS_System_Get_BS_ExtRam: .proc 
	r2 = [_TTS_Syllable_Num] 
	[R_Syllable_Num] = r2 
	r5 = R_DIC_Buffer; 
 
	//save it to Buffer 
	R2 = R_SACM_XXXX_ExtRam_In_Buffer_High 
	R1 = R_SACM_XXXX_ExtRam_In_Buffer_Low; 
	[_TTS1BIN_Dest_DS] = R2; 
	[_TTS1BIN_Dest_Addr] = R1; 
 
	R1 = R_DIC_Buffer; 
	r4 = [r1++] 
	[_Frame_Length] = R4; 
	[R_DIC_PTR] = r1 
		 
	R1 = R_START_ADDR_BUFFER 
	R3 = [R1++];		//L 
	R2 = [R1++];		//H 
	[R_ADDR_PTR] = R1;	//second DIC start addr 
 
	[_TTS1BIN_Curr_DS]=r2		 
	[_TTS1BIN_Curr_Addr]=r3	 
 
?_Branch_2: 
	//save tts1.bin in R_SACM_XXXX_ExtRam_In_Buffer 
	//S320TTS1BIN_Access_GetData(ULONG DesPtr,ULONG saPtr,short CopyLen) 
.ifdef FAT 
	call _S320TTS1BIN_Access_GetData	//in S320TTS1BIN_Access_byFAT.c 
.endif 
 
?_Check_DecodeInBuffer_Full: 
	R1 = [_TTS1BIN_Dest_Addr]; 
	R2 = R_SACM_XXXX_ExtRam_In_Buffer_Low + C_EXTRAM_IN_LENGTH; 
	cmp R1,R2; 
	jb ?_Change_Syllable; 
	goto ?_End; 
 
?_Change_Syllable:	 
	R1 = [R_Syllable_Num]; 
 	R1 -= 1; 
	[R_Syllable_Num] = R1; 
	jz ?_End; 
?_Refresh_Parameter: 
	R1 = [R_ADDR_PTR] 
	R3 = [R1++];		//low 
	R2 = [R1++];		//high 
	[R_ADDR_PTR] = R1 
	R1 = [R_DIC_PTR] 
	R4 = [R1++];		//length 
	[_Frame_Length] = R4;	//modified frame length 
	[R_DIC_PTR] = r1 
		 
?_LengthToPage: 
	// now R2,R3 is the start address * 4 
	 
	[_TTS1BIN_Curr_DS]=r2		 
	[_TTS1BIN_Curr_Addr]=r3	 
	goto ?_Branch_2 
		 
?_End: 
	R1 = R_SACM_XXXX_ExtRam_In_Buffer_High; 
	[_TTS1BIN_Dest_DS] = R1; 
	R1 = R_SACM_XXXX_ExtRam_In_Buffer_Low; 
	[_TTS1BIN_Dest_Addr] = R1;	 
	RETF; 
.endp 
 
//---------------------------------------------------------- 
.endif	//C_SND_S320TTS_SUPPORT