/***********************/ /*** Speech Compiler ***/ /***********************/ #include #include #include #include #include #include #include #include #include #include #include using namespace std; //************************************************ #define CHUNKSIZE 2336 // XA track size #define SPACE ' ' #define MINUS '-' #define COMMENT '#' #define TAB 0x09 #define EOL 0x0d #define InFileEXT "Ixa" #define OutFileEXT "XaB" #define BANK_SHIFT 16 //************************************************ struct sLang { char *Dir; char Prefix; }; struct sInFile { char Name[256]; int Chunks; int Offset; }; //************************************************ char *Script; char *OutDir="",*ScriptFile=0; int IncFileSet=0; char IncludeFilename[256]; int BankNo=0; char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; char fname[_MAX_FNAME]; char ext[_MAX_EXT]; std::vector LangList; std::vector FileList; //*********************************************************************** //*********************************************************************** static void app_debug_msg(const char * pszFmt,va_list args) { char szBuf[256]; vsprintf(szBuf,pszFmt,args); printf("%s\n",szBuf); } //****************************************************************** //****************************************************************** void __cdecl DEBUG(const char * pszFmt,...) { if (pszFmt) { va_list args; va_start(args,pszFmt); app_debug_msg(pszFmt,args); va_end(args); } } void __cdecl FATAL(const char * pszFmt,...) { if (pszFmt) { va_list args; va_start(args,pszFmt); app_debug_msg(pszFmt,args); va_end(args); } exit(123); } //****************************************************************** char *LoadFileInMem(const char * pszName) { HANDLE FileHandle; DWORD SizeRead; char *Buffer; char TName[256]; int Size; sprintf(TName,pszName); if( (FileHandle = CreateFile(TName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL)) == INVALID_HANDLE_VALUE ) { FATAL("ERROR : Could not open file %s.",TName); return NULL; } else { Size = GetFileSize(FileHandle,NULL); if( (Buffer=(char*)malloc(Size))==NULL ) {printf("Out of memory.\n");exit(123);} ReadFile(FileHandle,(void*)Buffer,Size,&SizeRead,NULL); CloseHandle(FileHandle); } return Buffer; } //****************************************************************** int FindFileSize(const char * FileName) { HANDLE FileHandle; DWORD Size; char TName[256]; sprintf(TName,FileName); if( (FileHandle = CreateFile(TName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL)) == INVALID_HANDLE_VALUE ) { FATAL("ERROR : Could not open file %s.",TName); return (0); } else { Size = GetFileSize(FileHandle,NULL); CloseHandle(FileHandle); } return (Size); } int FindFileSizeAlign(const char * FileName) { int Size=FindFileSize(FileName); Size = ((Size + 3) & 0xfffffffc); return(Size); } //****************************************************************** // Read pre-defined script file //****************************************************************** int IsWhiteSpace(char c) { if (c==' ') return(1); if (c==TAB) return(1); if (c==0xd) return(1); if (c==0xa) return(1); return(0); } //****************************************************************** char *SkipWhiteSpace(char *Ptr) { while (IsWhiteSpace(*Ptr)) Ptr++; return(Ptr); } //****************************************************************** char *GotoNextLine(char *Ptr) { while (*Ptr!=EOL) Ptr++; return(Ptr+2); } //****************************************************************** void ReadScript() { char *Ptr,*EndPtr; int Size; sInFile InFile; Script = (char *)LoadFileInMem( ScriptFile); Size = FindFileSize(ScriptFile); Ptr=Script; EndPtr=Ptr+Size; while (Ptr=EndPtr) return; if (*Ptr==COMMENT) { // Comment Ptr=GotoNextLine(Ptr); } else { int i=0; InFile.Chunks=0; while (!IsWhiteSpace(*Ptr) && Ptr