#include #include #include #include #include #include #include #include //#include "SfxList.h" //************************************************ #define MAX_SFX 1024 //************************************************ char path_buffer[_MAX_PATH]; char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; char fname[_MAX_FNAME]; char ext[_MAX_EXT]; struct bank_entry { WORD looped; WORD pitch; DWORD offset; }; typedef struct { char Name[ 100 ]; WORD SfxNo; BYTE Hashed; BYTE Looped; WORD LoopPos; } file_entry; char ThisDir[256]; file_entry FileList[MAX_SFX]; int NoFiles = 0; //*********************************************************************** //*********************************************************************** static void app_debug_msg(const char * pszFmt,va_list args) { char szBuf[256]; vsprintf(szBuf,pszFmt,args); printf("\n%s\n",szBuf); } //****************************************************************** //****************************************************************** void __cdecl screen_debug_msg(const char * pszFmt,...) { if (pszFmt) { va_list args; va_start(args,pszFmt); app_debug_msg(pszFmt,args); va_end(args); } } void __cdecl app_assert(const char * pszFmt,...) { if (pszFmt) { va_list args; va_start(args,pszFmt); app_debug_msg(pszFmt,args); va_end(args); } exit(123); } //****************************************************************** void FreePtr(void *p) { if(p) free(p); } //****************************************************************** BYTE* LoadFileInMem(const char * pszName) { HANDLE hsFile; DWORD dwSize = NULL; DWORD dwSize2 = NULL; DWORD Temp; BYTE* Buffer; if( (hsFile = CreateFile(pszName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL)) == INVALID_HANDLE_VALUE ) { screen_debug_msg("LFIM: Could not open file %s",pszName); return NULL; }else{ dwSize = GetFileSize(hsFile,NULL); dwSize2 = dwSize; if(dwSize&0x7) dwSize2 = (dwSize-(dwSize&0x7))+8; if( (Buffer=(BYTE*)malloc(dwSize2))==NULL ) {printf("Out of memory.\n");exit(123);} ReadFile(hsFile,(void*)Buffer,dwSize,&Temp,NULL); CloseHandle(hsFile); } return Buffer; } //****************************************************************** DWORD FindFileSize(const char * pszName) { HANDLE hsFile; DWORD dwSize=NULL; if( (hsFile = CreateFile(pszName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL)) == INVALID_HANDLE_VALUE ) { screen_debug_msg("\nFFS: Could not open file %s",pszName); return NULL; }else{ dwSize = GetFileSize(hsFile,NULL); if(dwSize&0x7) dwSize = (dwSize-(dwSize&0x7))+8; CloseHandle(hsFile); } return dwSize; } //*************************************************** // Find files in directory //*************************************************** int CalcHashNum(char* astring) { int result = 0; WORD count; for (count=0; count>8) + ((val&0xff000000)>>24); return(result); } void WriteBankData(char* Bank) { FILE* BANKFILE = NULL; FILE* OFFSETFILE = NULL; BYTE* Buffer = NULL; WORD Size; DWORD filepos = 0; char file[256]; bank_entry BankInfo; WORD pitch; DWORD vagpitch; sprintf(file,"%s.bnk",Bank); BANKFILE = fopen(file,"wb"); if(!BANKFILE) {printf("\nBank file error\n\n");return;} sprintf(file,"%s.bof",Bank); OFFSETFILE = fopen(file,"wb"); if(!OFFSETFILE) {printf("\nBank offset error\n\n");return;} for(int i=0;i', '?', '@', '{', '}', '[', ']', '¬', }; static const int nbBadFileChars = (sizeof(BadFileChars) / sizeof(char)); void ExportEnums(char * name) { FILE * ENUMFILE = NULL; char file[256]; _splitpath(name, drive, dir, fname, ext); strupr(fname); sprintf( file, "%s.h", name ); ENUMFILE = fopen(file,"wt"); if(!ENUMFILE) {printf("\nEnum file error\n\n");return;} fprintf( ENUMFILE, "enum\n{\n" ); for (int i=0;i=0;t--) { if( ostr[ t ] == '\\' ) { t++; break; } } int o = 0; for (;t "); printf("\nFor example, 'Banker level0.txt \\data\\snd\\level0' will take"); printf("\n'level0.txt' as its input and produce three files ( \\data\\snd\\level0.bof,"); printf("\n\\data\\snd\\level0.bnk and \\data\\snd\\level0.h ) as output."); printf("\n\n"); return(0); } FindDirFiles(argv[1]); WriteBankData(argv[2]); ExportEnums(argv[2]); printf("\nBank files made\n\n"); return(0); }