This commit is contained in:
commit
47aee91ef4
396 changed files with 32003 additions and 0 deletions
591
Utils/MkData/MkData.cpp
Normal file
591
Utils/MkData/MkData.cpp
Normal file
|
@ -0,0 +1,591 @@
|
|||
/************************/
|
||||
/*** DataFile Creator ***/
|
||||
/************************/
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include <io.h>
|
||||
#include <fstream.h>
|
||||
#include <conio.h>
|
||||
#include <vector>
|
||||
#include "Mkdata.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
//***********************************************************************
|
||||
//***********************************************************************
|
||||
//***********************************************************************
|
||||
int DebugFlag=0;
|
||||
int AlignSize=2048;
|
||||
char *AlignBuffer;
|
||||
|
||||
//***********************************************************************
|
||||
CBank Banks;
|
||||
CFileList Files;
|
||||
char *BaseDir=0;
|
||||
|
||||
//***********************************************************************
|
||||
|
||||
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 (DebugFlag)
|
||||
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 * FileName,int *OutSize)
|
||||
{
|
||||
FILE *FileHandle;
|
||||
char *Buffer;
|
||||
int Size;
|
||||
|
||||
FileHandle= fopen( FileName,"rb" );
|
||||
if(!FileHandle)
|
||||
{
|
||||
FATAL("ERROR : Could not open file %s\n",FileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
fseek(FileHandle,0,SEEK_END);
|
||||
Size=ftell(FileHandle);
|
||||
fseek(FileHandle,0,SEEK_SET);
|
||||
|
||||
if( (Buffer=(char*)malloc(Size))==NULL ) {printf("Out of memory.\n");exit(123);}
|
||||
fread(Buffer, 1,Size,FileHandle);
|
||||
fclose(FileHandle);
|
||||
}
|
||||
if (OutSize) *OutSize=Size;
|
||||
return Buffer;
|
||||
}
|
||||
|
||||
|
||||
//******************************************************************
|
||||
static char s_illegalChars[] = "\\/!£$%^&*()+-=-:. ";
|
||||
static int s_nbChars = sizeof(s_illegalChars);
|
||||
|
||||
void convertIllegalChar( char *c )
|
||||
{
|
||||
for (int i=0;i<s_nbChars;i++)
|
||||
{
|
||||
if (*c == s_illegalChars[i]) *c = '_';
|
||||
}
|
||||
}
|
||||
|
||||
//******************************************************************
|
||||
void ConvertString(char *Str)
|
||||
{
|
||||
strupr(Str);
|
||||
while(*Str) convertIllegalChar(Str++);
|
||||
}
|
||||
|
||||
//******************************************************************
|
||||
void MakeEqName(char *In,char *Out)
|
||||
{
|
||||
int StrLen=strlen(In);
|
||||
int begin0 = 0;
|
||||
int begin1 = 0;
|
||||
|
||||
for (int i=0;i<StrLen;i++)
|
||||
{
|
||||
if (In[i] == '/' || In[i] == '\\')
|
||||
{
|
||||
begin0 = begin1;
|
||||
begin1 = i;
|
||||
}
|
||||
}
|
||||
if (In[begin0]=='/' || In[begin0]=='\\') begin0++;
|
||||
strcpy(Out,In+begin0);
|
||||
ConvertString(Out);
|
||||
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
//*** CFileList *********************************************************
|
||||
//***********************************************************************
|
||||
CFileList::~CFileList()
|
||||
{
|
||||
int ListSize=FileList.size();
|
||||
for (int i=0;i<ListSize;i++) if (!FileList[i].BankIdx) free(FileList[i].Data);
|
||||
|
||||
}
|
||||
//***********************************************************************
|
||||
int CFileList::FindFileIdx(char *Filename)
|
||||
{
|
||||
int ListSize=FileList.size();
|
||||
for (int i=0;i<ListSize;i++) if (!strcmp(Filename,FileList[i].Filename)) return(i);
|
||||
return(-1);
|
||||
|
||||
}
|
||||
//***********************************************************************
|
||||
int CFileList::AddFile(char *BaseFilename,int BankIdx)
|
||||
{
|
||||
int Idx;
|
||||
sFile File;
|
||||
|
||||
File.BankIdx=BankIdx;
|
||||
strupr(BaseFilename);
|
||||
sprintf(File.Filename,"%s/%s",BaseDir,BaseFilename);
|
||||
MakeEqName(File.Filename,File.ShortName);
|
||||
Idx=FindFileIdx(File.Filename);
|
||||
|
||||
if (Idx==-1)
|
||||
{
|
||||
Idx=FileList.size();
|
||||
if (!BankIdx)
|
||||
{
|
||||
File.Data=LoadFileInMem(File.Filename,&File.Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
File.BankIdx=BankIdx;
|
||||
}
|
||||
FileList.push_back(File);
|
||||
}
|
||||
return(Idx);
|
||||
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
//*** CBank *************************************************************
|
||||
//***********************************************************************
|
||||
void CBank::Start(char *Name,int Align)
|
||||
{
|
||||
sBank B;
|
||||
if (Align==0) Align=AlignSize;
|
||||
strcpy(B.Name,Name);
|
||||
B.Align=Align;
|
||||
CurrentBank=BankList.size();
|
||||
BankList.push_back(B);
|
||||
if (CurrentBank) Files.AddFile(Name,CurrentBank);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
void CBank::End()
|
||||
{
|
||||
CurrentBank=0;
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
int CBank::FindEntry(int Idx)
|
||||
{
|
||||
sBank &ThisBank=GetBank(CurrentBank);
|
||||
|
||||
int ListSize=ThisBank.FileList.size();
|
||||
|
||||
for (int i=0;i<ListSize;i++)
|
||||
{
|
||||
if (ThisBank.FileList[i].ListIdx==Idx) return(i);
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
void CBank::Add(char *Filename)
|
||||
{
|
||||
sBankEntry Entry;
|
||||
|
||||
if (Filename[0]==CHAR_SKIP) {Files.AddFile(Filename+1); return;}
|
||||
Entry.ListIdx=Files.AddFile(Filename);
|
||||
if (FindEntry(Entry.ListIdx)==-1) BankList[CurrentBank].FileList.push_back(Entry);
|
||||
}
|
||||
|
||||
//******************************************************************
|
||||
//*** Script shite *************************************************
|
||||
//******************************************************************
|
||||
int IsWhiteSpace(char c)
|
||||
{
|
||||
if (c==' ') return(1);
|
||||
if (c==CHAR_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 && *Ptr!=CHAR_EOL ) Ptr++;
|
||||
return(Ptr+2);
|
||||
}
|
||||
|
||||
//******************************************************************
|
||||
void Line2Str(char *Ptr,char *EndPtr)
|
||||
{
|
||||
int i=0;
|
||||
while (!IsWhiteSpace(*Ptr) && Ptr<EndPtr) Ptr++;
|
||||
*Ptr=0;
|
||||
}
|
||||
|
||||
//******************************************************************
|
||||
char *ScriptComment(char *Ptr,char *EndPtr)
|
||||
{
|
||||
return(GotoNextLine(Ptr));
|
||||
}
|
||||
|
||||
//******************************************************************
|
||||
char *ScriptStartBank(char *Ptr,char *EndPtr)
|
||||
{
|
||||
int Align;
|
||||
char *Name;
|
||||
|
||||
Ptr=SkipWhiteSpace(Ptr+1);
|
||||
Line2Str(Ptr,EndPtr);
|
||||
Name=Ptr;
|
||||
Ptr+=strlen(Ptr)+1;
|
||||
Align=atoi(Ptr);
|
||||
DEBUG("[%s] (%i)\n\t{",Name,Align);
|
||||
Banks.Start(Name,Align);
|
||||
return(GotoNextLine(Ptr));
|
||||
}
|
||||
|
||||
//******************************************************************
|
||||
char *ScriptEndBank(char *Ptr,char *EndPtr)
|
||||
{
|
||||
DEBUG("\t}");
|
||||
Banks.End();
|
||||
return(GotoNextLine(Ptr));
|
||||
}
|
||||
|
||||
//******************************************************************
|
||||
char *ScriptFile(char *Ptr,char *EndPtr)
|
||||
{
|
||||
Line2Str(Ptr,EndPtr);
|
||||
Banks.Add(Ptr);
|
||||
if (DebugFlag)
|
||||
{
|
||||
if (Banks.GetCurrentBankNo()) printf("\t");
|
||||
printf("%s\n",Ptr);
|
||||
}
|
||||
return(GotoNextLine(Ptr));
|
||||
}
|
||||
|
||||
//******************************************************************
|
||||
void ReadScript(char *Filename)
|
||||
{
|
||||
char *Script,*Ptr,*EndPtr;
|
||||
int Size;
|
||||
Script = (char *)LoadFileInMem( Filename,&Size);
|
||||
Ptr=Script;
|
||||
EndPtr=Ptr+Size;
|
||||
|
||||
printf("Reading %s\n",Filename);
|
||||
while (Ptr<EndPtr)
|
||||
{
|
||||
Ptr=SkipWhiteSpace(Ptr);
|
||||
if (Ptr>=EndPtr) return;
|
||||
switch (*Ptr)
|
||||
{
|
||||
case CHAR_COMMENT:
|
||||
Ptr=ScriptComment(Ptr,EndPtr);
|
||||
break;
|
||||
case CHAR_STARTBANK:
|
||||
Ptr=ScriptStartBank(Ptr,EndPtr);
|
||||
break;
|
||||
case CHAR_ENDBANK:
|
||||
Ptr=ScriptEndBank(Ptr,EndPtr);
|
||||
break;
|
||||
default:
|
||||
Ptr=ScriptFile(Ptr,EndPtr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(Script);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
//***********************************************************************
|
||||
//***********************************************************************
|
||||
void ResetFAT(std::vector<sFAT> &FAT)
|
||||
{
|
||||
int FATSize=Files.GetCount();
|
||||
int Loop;
|
||||
|
||||
FAT.resize(FATSize);
|
||||
for (Loop=0; Loop<FATSize; Loop++)
|
||||
{
|
||||
sFile &F=Files.GetFile(Loop);
|
||||
FAT[Loop].FilePos=-1;
|
||||
FAT[Loop].FileSize=F.Size;
|
||||
}
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
void AlignData(FILE *FileHandle,int Align)
|
||||
{
|
||||
int Pos=ftell(FileHandle);
|
||||
int AlignPad= (Pos & (Align-1));
|
||||
if (AlignPad) fwrite(AlignBuffer,1,Align-AlignPad,FileHandle);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
int WriteFAT(FILE *FileHandle,std::vector<sFAT> &FAT,int Align)
|
||||
{
|
||||
int Pos=ftell(FileHandle);
|
||||
int FATSize=Files.GetCount();
|
||||
|
||||
for (int Loop=0;Loop<FATSize;Loop++)
|
||||
{
|
||||
fwrite(&FAT[Loop],1,sizeof(sFAT),FileHandle);
|
||||
}
|
||||
AlignData(FileHandle,Align);
|
||||
|
||||
return(Pos);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
void WriteFileData(FILE *FileHandle,sFile &File,int Align,sFAT &ParentFAT)
|
||||
{
|
||||
ParentFAT.FilePos=ftell(FileHandle);
|
||||
ParentFAT.FileSize=File.Size;
|
||||
|
||||
fwrite(File.Data,1,File.Size,FileHandle);
|
||||
AlignData(FileHandle,Align);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
void WriteBankData(FILE *FileHandle,int BankIdx,sFAT &ParentFAT)
|
||||
{
|
||||
std::vector<sFAT> FAT;
|
||||
sBank &ThisBank=Banks.GetBank(BankIdx);
|
||||
int ThisListSize=ThisBank.FileList.size();
|
||||
int Loop;
|
||||
long StartFilePos,EndFilePos;
|
||||
|
||||
// reset FAT and write dummy FAT
|
||||
ResetFAT(FAT);
|
||||
ParentFAT.FilePos=WriteFAT(FileHandle,FAT,ThisBank.Align);
|
||||
StartFilePos=ftell(FileHandle);;
|
||||
|
||||
// Write files
|
||||
|
||||
for (Loop=0; Loop<ThisListSize; Loop++)
|
||||
{
|
||||
int Idx=ThisBank.FileList[Loop].ListIdx;
|
||||
sFile &ThisFile=Files.GetFile(Idx);
|
||||
WriteFileData(FileHandle,ThisFile,ThisBank.Align,FAT[Idx]);
|
||||
FAT[Idx].FilePos-=ParentFAT.FilePos;
|
||||
DEBUG("\t %s %i %i",ThisFile.Filename,FAT[Idx].FilePos,FAT[Idx].FileSize);
|
||||
}
|
||||
|
||||
EndFilePos=ftell(FileHandle);
|
||||
fseek(FileHandle,ParentFAT.FilePos,SEEK_SET);
|
||||
WriteFAT(FileHandle,FAT,ThisBank.Align);
|
||||
fseek(FileHandle,EndFilePos,SEEK_SET);
|
||||
|
||||
ParentFAT.FileSize=EndFilePos-StartFilePos;
|
||||
// printf("%i %i\n",BankSize,ParentFAT.FileSize);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
void WriteData(char *Filename)
|
||||
{
|
||||
FILE *FileHandle;
|
||||
std::vector<sFAT> FAT;
|
||||
int FATSize=Files.GetCount(),Idx;
|
||||
|
||||
FileHandle= fopen( Filename,"wb" );
|
||||
if(!FileHandle) FATAL( "Could not write %s", Filename);
|
||||
ResetFAT(FAT);
|
||||
WriteFAT(FileHandle,FAT,AlignSize);
|
||||
for (Idx=0; Idx<FATSize; Idx++)
|
||||
{
|
||||
sFile &ThisFile=Files.GetFile(Idx);
|
||||
if (ThisFile.BankIdx)
|
||||
{ // Databank
|
||||
DEBUG("Bank %s",ThisFile.Filename);
|
||||
WriteBankData(FileHandle,ThisFile.BankIdx,FAT[Idx]);
|
||||
FAT[Idx].FileSize+=FATSize*sizeof(FAT);
|
||||
// printf("%i\n",(int)FAT[Idx].FileSize);
|
||||
|
||||
AlignData(FileHandle,AlignSize);
|
||||
}
|
||||
else
|
||||
{ // Normal File
|
||||
WriteFileData(FileHandle,ThisFile,AlignSize,FAT[Idx]);
|
||||
DEBUG("%s %i %i",ThisFile.Filename,FAT[Idx].FilePos,FAT[Idx].FileSize);
|
||||
}
|
||||
}
|
||||
|
||||
fseek(FileHandle,0,SEEK_SET);
|
||||
WriteFAT(FileHandle,FAT,AlignSize);
|
||||
fclose(FileHandle);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
//***********************************************************************
|
||||
//***********************************************************************
|
||||
void WriteFileHeader(FILE *FileHandle,char *Name)
|
||||
{
|
||||
static Count=0;
|
||||
|
||||
if (!Count)
|
||||
fprintf( FileHandle, "%s=%i,\n" ,Name,Count);
|
||||
else
|
||||
fprintf( FileHandle, "%s,\n" ,Name);
|
||||
|
||||
Count++;
|
||||
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
void WriteBankHeader(FILE *FileHandle,int BankIdx)
|
||||
{
|
||||
sBank &ThisBank=Banks.GetBank(BankIdx);
|
||||
|
||||
WriteFileHeader(FileHandle,ThisBank.Name);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
void WriteHeader(char *Filename)
|
||||
{
|
||||
FILE *FileHandle;
|
||||
int FATSize=Files.GetCount(),Idx;
|
||||
|
||||
|
||||
FileHandle= fopen( Filename,"wb" );
|
||||
if(!FileHandle) FATAL( "Could not write %s", Filename);
|
||||
fprintf( FileHandle, "#ifndef __FILE_EQUATES_H__\n");
|
||||
fprintf( FileHandle, "#define __FILE_EQUATES_H__\n\n");
|
||||
fprintf( FileHandle, "enum FileEquate\n" );
|
||||
fprintf( FileHandle, "{\n" );
|
||||
|
||||
for (Idx=0; Idx<FATSize; Idx++)
|
||||
{
|
||||
sFile &ThisFile=Files.GetFile(Idx);
|
||||
if (ThisFile.BankIdx)
|
||||
{ // Databank
|
||||
WriteBankHeader(FileHandle,ThisFile.BankIdx);
|
||||
}
|
||||
else
|
||||
{ // Normal File
|
||||
WriteFileHeader(FileHandle,ThisFile.ShortName);
|
||||
}
|
||||
}
|
||||
|
||||
fprintf( FileHandle, "\nFileEquate_MAX,\n");
|
||||
fprintf( FileHandle, "};\n" );
|
||||
fprintf( FileHandle, "#endif\n" );
|
||||
|
||||
fclose(FileHandle);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
//***********************************************************************
|
||||
//***********************************************************************
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *DataFilename=0;
|
||||
char *IncludeFilename=0;
|
||||
std::vector<char*> Scripts;
|
||||
// Parse Input
|
||||
for (int Loop=1;Loop<argc;Loop++)
|
||||
{
|
||||
char *StrPtr=argv[Loop];
|
||||
if (StrPtr[0]=='-') StrPtr++;
|
||||
switch(StrPtr[0])
|
||||
{
|
||||
case 'o': // Output
|
||||
if(*StrPtr=':')StrPtr++;
|
||||
DataFilename=StrPtr+1;
|
||||
break;
|
||||
case 's': // script
|
||||
if(*StrPtr=':')StrPtr++;
|
||||
Scripts.push_back(StrPtr+1);
|
||||
break;
|
||||
case 'i': // include file
|
||||
if(*StrPtr=':')StrPtr++;
|
||||
IncludeFilename=StrPtr+1;
|
||||
break;
|
||||
case 'd': // Cache script
|
||||
DebugFlag=1;
|
||||
break;
|
||||
case 'a': // Align Size
|
||||
if(*StrPtr=':')StrPtr++;
|
||||
AlignSize=atoi(StrPtr+1);
|
||||
break;
|
||||
case 'b': // Base Dir
|
||||
if(*StrPtr=':')StrPtr++;
|
||||
BaseDir=StrPtr+1;
|
||||
break;
|
||||
default:
|
||||
printf("Unknown Param [%s]\n",StrPtr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!AlignSize) FATAL("ERROR: AlignSize is 0");
|
||||
|
||||
if(!DataFilename || !Scripts.size() || !BaseDir)
|
||||
{
|
||||
printf("Error in command line\n");
|
||||
printf("Usage : MkData [files] -o:OutFile\n");
|
||||
printf(" -s\tIn Script\n");
|
||||
printf(" -i\tHeaderFile\n");
|
||||
printf(" -a\tAlignSize (Default 2048)\n");
|
||||
printf(" -d\tDebug Msgs\n");
|
||||
printf(" -b\tBase Dir\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
if( (AlignBuffer=(char*)malloc(AlignSize))==NULL ) {printf("Couldnt Alloc AlignBuffer.\n");exit(123);}
|
||||
for (int i=0;i<AlignSize;i++) AlignBuffer[i]=0;
|
||||
|
||||
strupr(DataFilename);
|
||||
printf("Creating Data File: %s\n",DataFilename);
|
||||
Banks.Start("",AlignSize);
|
||||
for (int Script=0;Script<Scripts.size();Script++)
|
||||
{
|
||||
ReadScript(Scripts[Script]);
|
||||
}
|
||||
|
||||
printf("Writing Data File: %s\n",DataFilename);
|
||||
WriteData(DataFilename);
|
||||
if (IncludeFilename) WriteHeader(IncludeFilename);
|
||||
printf("FATSize =%i\n",Files.GetCount()*sizeof(sFAT));
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
97
Utils/MkData/MkData.dsp
Normal file
97
Utils/MkData/MkData.dsp
Normal file
|
@ -0,0 +1,97 @@
|
|||
# Microsoft Developer Studio Project File - Name="MkData" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=MkData - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "MkData.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "MkData.mak" CFG="MkData - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "MkData - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "MkData - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""$/PRLSR/utils/MkData", BLVAAAAA"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "MkData - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x809 /d "NDEBUG"
|
||||
# ADD RSC /l 0x809 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../../tools/MkData.exe"
|
||||
|
||||
!ELSEIF "$(CFG)" == "MkData - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
# ADD RSC /l 0x809 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "MkData - Win32 Release"
|
||||
# Name "MkData - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MkData.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MkData.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
86
Utils/MkData/MkData.h
Normal file
86
Utils/MkData/MkData.h
Normal file
|
@ -0,0 +1,86 @@
|
|||
/************************/
|
||||
/*** DataFile Creator ***/
|
||||
/************************/
|
||||
|
||||
//***********************************************************************
|
||||
//***********************************************************************
|
||||
//***********************************************************************
|
||||
#define CHAR_COMMENT '#'
|
||||
#define CHAR_TAB 0x09
|
||||
#define CHAR_EOL 0x0d
|
||||
#define CHAR_SKIP '-'
|
||||
#define CHAR_STARTBANK '{'
|
||||
#define CHAR_ENDBANK '}'
|
||||
|
||||
//***********************************************************************
|
||||
//***********************************************************************
|
||||
//***********************************************************************
|
||||
typedef signed char s8;
|
||||
typedef signed short s16;
|
||||
typedef signed long s32;
|
||||
|
||||
//***********************************************************************
|
||||
//***********************************************************************
|
||||
//***********************************************************************
|
||||
struct sFAT
|
||||
{
|
||||
s32 FilePos;
|
||||
s32 FileSize;
|
||||
};
|
||||
|
||||
struct sBankEntry
|
||||
{
|
||||
int ListIdx;
|
||||
int Pos;
|
||||
};
|
||||
|
||||
struct sBank
|
||||
{
|
||||
char Name[256];
|
||||
int Align;
|
||||
std::vector<sBankEntry> FileList;
|
||||
};
|
||||
|
||||
struct sFile
|
||||
{
|
||||
char Filename[256];
|
||||
char ShortName[256];
|
||||
int Size;
|
||||
char *Data;
|
||||
int BankIdx;
|
||||
};
|
||||
|
||||
//***********************************************************************
|
||||
class CFileList
|
||||
{
|
||||
public:
|
||||
CFileList(){};
|
||||
~CFileList();
|
||||
int FindFileIdx(char *Filename);
|
||||
int AddFile(char *Filename,int BankIdx=0);
|
||||
int GetCount() {return(FileList.size());}
|
||||
sFile &GetFile(int Idx) {return(FileList[Idx]);}
|
||||
|
||||
private:
|
||||
|
||||
std::vector<sFile> FileList;
|
||||
};
|
||||
|
||||
//***********************************************************************
|
||||
class CBank
|
||||
{
|
||||
public:
|
||||
void Start(char *Name,int Align=0);
|
||||
void End();
|
||||
int FindEntry(int Idx);
|
||||
void Add(char *Filename);
|
||||
int GetCount() {return(BankList.size());}
|
||||
sBank &GetBank(int Idx) {return(BankList[Idx]);}
|
||||
int GetCurrentBankNo() {return(CurrentBank);}
|
||||
|
||||
private:
|
||||
int CurrentBank;
|
||||
std::vector<sBank> BankList;
|
||||
};
|
||||
|
||||
//***********************************************************************
|
413
Utils/MkSpeech/MkSpeech.cpp
Normal file
413
Utils/MkSpeech/MkSpeech.cpp
Normal file
|
@ -0,0 +1,413 @@
|
|||
/***********************/
|
||||
/*** Speech Compiler ***/
|
||||
/***********************/
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include <io.h>
|
||||
#include <fstream.h>
|
||||
#include <conio.h>
|
||||
#include <vector>
|
||||
|
||||
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[32];
|
||||
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<sLang> LangList;
|
||||
std::vector<sInFile> 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)
|
||||
{
|
||||
Ptr=SkipWhiteSpace(Ptr);
|
||||
if (Ptr>=EndPtr) return;
|
||||
if (*Ptr==COMMENT)
|
||||
{ // Comment
|
||||
Ptr=GotoNextLine(Ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
int i=0;
|
||||
InFile.Chunks=0;
|
||||
while (!IsWhiteSpace(*Ptr) && Ptr<EndPtr) InFile.Name[i++]=*Ptr++;
|
||||
InFile.Name[i]=0;
|
||||
FileList.push_back(InFile);
|
||||
// printf("%s\n",InFile.Name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//******************************************************************
|
||||
//*** Get File Sizes ***********************************************
|
||||
//******************************************************************
|
||||
void GetFileSizes()
|
||||
{
|
||||
int FileCount=FileList.size();
|
||||
int LangCount=LangList.size();
|
||||
char FileName[256];
|
||||
|
||||
// DEBUG( "Parsing Files");
|
||||
for (int File=0; File<FileCount; File++)
|
||||
{
|
||||
sInFile &ThisFile=FileList[File];
|
||||
ThisFile.Chunks=0;
|
||||
for (int Lang=0; Lang<LangCount; Lang++)
|
||||
{
|
||||
sLang &ThisLang=LangList[Lang];
|
||||
int ThisFileSize;
|
||||
int ThisChunkSize;
|
||||
sprintf(FileName,"%s\\%c%s.%s", ThisLang.Dir, ThisLang.Prefix, ThisFile.Name, InFileEXT);
|
||||
ThisFileSize=FindFileSize(FileName);
|
||||
ThisChunkSize=(ThisFileSize+(CHUNKSIZE-1))/CHUNKSIZE;
|
||||
if (ThisFile.Chunks<ThisChunkSize) ThisFile.Chunks=ThisChunkSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//******************************************************************
|
||||
//*** Write Data ***************************************************
|
||||
//******************************************************************
|
||||
void WriteData(sLang &ThisLang)
|
||||
{
|
||||
char *Buffer;
|
||||
char FileName[256];
|
||||
FILE *OutFile;
|
||||
char Blank[CHUNKSIZE];
|
||||
int FileCount=FileList.size();
|
||||
|
||||
memset( Blank, 0xBA, CHUNKSIZE ); // clear Blank Buffer
|
||||
sprintf(FileName,"%s%c%s.%s",OutDir,ThisLang.Prefix ,fname,OutFileEXT);
|
||||
OutFile= fopen( FileName,"wb" );
|
||||
if(!OutFile)
|
||||
FATAL( "Could not write %s", FileName);
|
||||
else
|
||||
DEBUG( "Created File - %s", FileName);
|
||||
|
||||
for (int File=0; File<FileCount; File++)
|
||||
{
|
||||
sInFile &ThisFile=FileList[File];
|
||||
int ThisFileSize;
|
||||
sprintf(FileName,"%s\\%c%s.%s", ThisLang.Dir, ThisLang.Prefix, ThisFile.Name, InFileEXT);
|
||||
Buffer=LoadFileInMem(FileName);
|
||||
ThisFileSize=FindFileSize(FileName);
|
||||
fwrite( Buffer, 1, ThisFileSize, OutFile);
|
||||
fwrite( Blank, 1, (ThisFile.Chunks*CHUNKSIZE)-ThisFileSize, OutFile); // Write Pad
|
||||
fwrite( Blank, 1, CHUNKSIZE, OutFile); // Force Pad
|
||||
ThisFile.Offset=ftell(OutFile);
|
||||
free(Buffer);
|
||||
}
|
||||
fclose(OutFile);
|
||||
}
|
||||
|
||||
|
||||
//******************************************************************
|
||||
//*** Write Header File ********************************************
|
||||
//******************************************************************
|
||||
static char s_illegalChars[] = "\\/!£$%^&*()+-=-:. ";
|
||||
static int s_nbChars = sizeof(s_illegalChars);
|
||||
|
||||
void convertIllegalChar( char *c )
|
||||
{
|
||||
for (int i=0;i<s_nbChars;i++)
|
||||
{
|
||||
if (*c == s_illegalChars[i]) *c = '_';
|
||||
}
|
||||
}
|
||||
|
||||
//******************************************************************
|
||||
void ConvertString(char *Str) {while(*Str) convertIllegalChar(Str++);}
|
||||
|
||||
//******************************************************************
|
||||
void WriteHeader(sLang &ThisLang)
|
||||
{
|
||||
FILE *OutFile;
|
||||
char HdrStr[256];
|
||||
char EqStr[256];
|
||||
int FileCount=FileList.size();
|
||||
int Offset=0;
|
||||
|
||||
sprintf(HdrStr,"__%s_SPEECH_DEFINES_H__",strupr(fname));
|
||||
sprintf(EqStr,"%s_STR_",strupr(fname));
|
||||
|
||||
OutFile= fopen( IncludeFilename,"wt" );
|
||||
if(!OutFile)
|
||||
FATAL( "Could not write %s", IncludeFilename);
|
||||
else
|
||||
DEBUG( "Created File - %s", IncludeFilename);
|
||||
|
||||
fprintf( OutFile, "#ifndef %s\n",HdrStr);
|
||||
fprintf( OutFile, "#define %s\n\n",HdrStr);
|
||||
fprintf( OutFile, "enum %sENUMS\n" ,EqStr);
|
||||
fprintf( OutFile, "{\n" );
|
||||
|
||||
for (int File=0; File<FileCount; File++)
|
||||
{
|
||||
sInFile &ThisFile=FileList[File];
|
||||
|
||||
ConvertString(ThisFile.Name);
|
||||
fprintf( OutFile, "%s%s = 0x%x,\n", EqStr,ThisFile.Name, Offset+(BankNo<<BANK_SHIFT));
|
||||
Offset+=ThisFile.Chunks+1; // +1 for pad
|
||||
}
|
||||
fprintf( OutFile, "};\n" );
|
||||
fprintf( OutFile, "#endif\n" );
|
||||
|
||||
fclose(OutFile);
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
//***************************************************
|
||||
//***************************************************
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int CmdError=0;
|
||||
|
||||
// Parse Input
|
||||
for (int Loop=1;Loop<argc;Loop++)
|
||||
{
|
||||
char *StrPtr=argv[Loop];
|
||||
if (StrPtr[0]!='-') CmdError=1;
|
||||
StrPtr++;
|
||||
switch(StrPtr[0])
|
||||
{
|
||||
case 'o': // Output
|
||||
OutDir=StrPtr+1;
|
||||
break;
|
||||
|
||||
case 'd': // Add In Dir
|
||||
{
|
||||
sLang Dir;
|
||||
Dir.Prefix=StrPtr[1];
|
||||
Dir.Dir=StrPtr+2;
|
||||
LangList.push_back(Dir);
|
||||
DEBUG("Added Lang:%s",Dir.Dir);
|
||||
}
|
||||
break;
|
||||
|
||||
case 's': // script
|
||||
ScriptFile=StrPtr+1;
|
||||
break;
|
||||
case 'i': // script
|
||||
IncFileSet=1;
|
||||
strcpy(IncludeFilename,StrPtr+1);
|
||||
break;
|
||||
case 'b': // script
|
||||
BankNo=atoi(StrPtr+1);
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Unknown Param [%s]\n",StrPtr);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!ScriptFile || !LangList.size())
|
||||
{
|
||||
DEBUG("Error in command line");
|
||||
DEBUG("Usage : MkSpeech");
|
||||
DEBUG(" -d\tAdd Dir (Prefix & Dir= -dPddddd)");
|
||||
DEBUG(" -o\tOut Dir");
|
||||
DEBUG(" -s\tScript");
|
||||
DEBUG(" -I\tHeaderFile");
|
||||
DEBUG(" -B\tBankNo");
|
||||
return(0);
|
||||
}
|
||||
|
||||
_splitpath( ScriptFile, drive, dir, fname, ext );
|
||||
|
||||
if (!IncFileSet) sprintf(IncludeFilename,"%s%s.h",fname,"_Speech",OutFileEXT);
|
||||
|
||||
ReadScript();
|
||||
// DEBUG( "Script Read.");
|
||||
GetFileSizes();
|
||||
|
||||
int LangCount=LangList.size();
|
||||
for (int Lang=0;Lang<LangCount; Lang++) WriteData(LangList[Lang]);
|
||||
WriteHeader(LangList[0]);
|
||||
|
||||
DEBUG("Success.");
|
||||
|
||||
return(0);
|
||||
}
|
101
Utils/MkSpeech/MkSpeech.dsp
Normal file
101
Utils/MkSpeech/MkSpeech.dsp
Normal file
|
@ -0,0 +1,101 @@
|
|||
# Microsoft Developer Studio Project File - Name="MkSpeech" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=MkSpeech - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "MkSpeech.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "MkSpeech.mak" CFG="MkSpeech - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "MkSpeech - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "MkSpeech - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "MkSpeech - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x809 /d "NDEBUG"
|
||||
# ADD RSC /l 0x809 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"C:\PRLSR\tools\MkSpeech.exe"
|
||||
|
||||
!ELSEIF "$(CFG)" == "MkSpeech - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
# ADD RSC /l 0x809 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "MkSpeech - Win32 Release"
|
||||
# Name "MkSpeech - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MkSpeech.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
94
Utils/banker/banker.dsp
Normal file
94
Utils/banker/banker.dsp
Normal file
|
@ -0,0 +1,94 @@
|
|||
# Microsoft Developer Studio Project File - Name="banker" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=banker - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "banker.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "banker.mak" CFG="banker - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "banker - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "banker - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""$/PRLSR/utils/banker", KJRAAAAA"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "banker - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x809 /d "NDEBUG"
|
||||
# ADD RSC /l 0x809 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"..\..\tools\banker.exe"
|
||||
|
||||
!ELSEIF "$(CFG)" == "banker - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
# ADD RSC /l 0x809 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"..\..\tools\banker.exe" /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "banker - Win32 Release"
|
||||
# Name "banker - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\main.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
399
Utils/banker/main.cpp
Normal file
399
Utils/banker/main.cpp
Normal file
|
@ -0,0 +1,399 @@
|
|||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include <io.h>
|
||||
|
||||
//#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<strlen(astring); count++)
|
||||
{
|
||||
result^=(int) astring[count];
|
||||
result++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FindDirFiles(char * Search)
|
||||
{
|
||||
int i;
|
||||
FILE *fh;
|
||||
char loop;
|
||||
|
||||
|
||||
/* De-hash table */
|
||||
for(i=0;i<MAX_SFX;i++)
|
||||
{
|
||||
FileList[i].Name[ 0 ] = '\0';
|
||||
FileList[i].Hashed = false;
|
||||
FileList[i].Looped = false;
|
||||
}
|
||||
|
||||
|
||||
// Open source file
|
||||
if( ( fh = fopen( Search, "rb" ) ) == NULL )
|
||||
{
|
||||
printf( "\nCan't find source file!\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
// Scan source file
|
||||
while( !feof( fh ) )
|
||||
{
|
||||
if( fscanf( fh, "%s %c %d", FileList[NoFiles].Name, &loop, &FileList[NoFiles].LoopPos ) != 3 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if( loop == 'y' || loop == 'Y' )
|
||||
{
|
||||
FileList[NoFiles].Looped = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
FileList[NoFiles].Looped = false;
|
||||
}
|
||||
FileList[NoFiles].Hashed = true;
|
||||
NoFiles++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
// Write files to bank
|
||||
//***************************************************
|
||||
|
||||
DWORD FlipLongWord(DWORD val)
|
||||
{
|
||||
DWORD result;
|
||||
|
||||
result = ((val&0x000000ff)<<24) + ((val&0x0000ff00)<<8) + ((val&0x00ff0000)>>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<NoFiles;i++)
|
||||
{
|
||||
if(FileList[i].Hashed)
|
||||
{
|
||||
char Name[256];
|
||||
sprintf(Name, "%s%s", ThisDir, FileList[i].Name);
|
||||
Buffer = LoadFileInMem(Name);
|
||||
if (Buffer)
|
||||
{
|
||||
Size = (WORD)FindFileSize(Name);
|
||||
Size -= 48;
|
||||
|
||||
printf("%s\t\t", Name);
|
||||
|
||||
if( FileList[i].Looped )
|
||||
{
|
||||
// Encode vag file as looped
|
||||
int LoopBlock = (int)( (float)FileList[i].LoopPos / 3.5f );
|
||||
for(int p=48+16;p<(LoopBlock)-16;p+=16)
|
||||
{
|
||||
Buffer[p+1] = 0x0;
|
||||
}
|
||||
|
||||
Buffer[p+1] = 0x6;
|
||||
for(p=p+16;p<(Size-16);p+=16)
|
||||
{
|
||||
Buffer[p+1] = 0x2;
|
||||
}
|
||||
Buffer[p+1] = 0x3;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// Encode vag file as non-looped
|
||||
for(int p=48;p<(Size-16);p+=16)
|
||||
{
|
||||
// Buffer[p+1] = 0x2;
|
||||
}
|
||||
Buffer[p+1] = 0x1;
|
||||
}
|
||||
|
||||
fwrite(Buffer+48, 1, Size, BANKFILE);
|
||||
|
||||
_splitpath(Name, drive, dir, fname, ext);
|
||||
|
||||
vagpitch = *(DWORD*)&Buffer[16];
|
||||
vagpitch = FlipLongWord(vagpitch);
|
||||
pitch=(int)((float)vagpitch*(1024.0/11025.0));
|
||||
printf(" pitch %dkhz (%d)\n",vagpitch,pitch);
|
||||
|
||||
BankInfo.offset = filepos;
|
||||
BankInfo.pitch = pitch;
|
||||
BankInfo.looped = FileList[i].Looped;
|
||||
|
||||
fwrite(&BankInfo, 1, sizeof(bank_entry), OFFSETFILE);
|
||||
|
||||
filepos += Size;
|
||||
|
||||
FreePtr(Buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(BANKFILE);
|
||||
fclose(OFFSETFILE);
|
||||
}
|
||||
|
||||
|
||||
static const char BadFileChars[] =
|
||||
{
|
||||
'+', '-', '*', '/', '\\', '#', ',',
|
||||
'.', '(', ')', '!', '"', '£', '$',
|
||||
'%', '^', '&', '=', '#', ':', ';', '<',
|
||||
'>', '?', '@', '{', '}', '[', ']', '¬',
|
||||
};
|
||||
|
||||
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<NoFiles;i++)
|
||||
{
|
||||
char * ostr = FileList[i].Name;//SFXNameTab[i];
|
||||
int len = (int)strlen(ostr)+1;
|
||||
char * nstr = new char[len];
|
||||
|
||||
for (int t=len-1;t>=0;t--)
|
||||
{
|
||||
if( ostr[ t ] == '\\' )
|
||||
{
|
||||
t++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int o = 0;
|
||||
for (;t<len;t++)
|
||||
{
|
||||
nstr[o] = ostr[t];
|
||||
if (nstr[o] == '.') nstr[o] = 0;
|
||||
for(int c=0;c<nbBadFileChars;c++)
|
||||
{
|
||||
if (nstr[o] == BadFileChars[c]) nstr[o] = '_';
|
||||
}
|
||||
o++;
|
||||
}
|
||||
|
||||
strupr( nstr );
|
||||
|
||||
if( FileList[i].Looped )
|
||||
{
|
||||
fprintf( ENUMFILE, "\tSFX_%s_%s,\t\t// Looped at %d\n", fname,nstr, FileList[i].LoopPos );
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( ENUMFILE, "\tSFX_%s_%s,\n", fname,nstr );
|
||||
}
|
||||
}
|
||||
fprintf( ENUMFILE, "};\n" );
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
//***************************************************
|
||||
//***************************************************
|
||||
//***************************************************
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
if(argc!=3)
|
||||
{
|
||||
printf("\nBanker (C)limax 1997");
|
||||
printf("\nWritten by Tim Swann");
|
||||
printf("\nUsage: Banker <Source File> <Output Base>");
|
||||
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);
|
||||
}
|
472
Utils/parkgrab/VImage.cpp
Normal file
472
Utils/parkgrab/VImage.cpp
Normal file
|
@ -0,0 +1,472 @@
|
|||
/*=========================================================================
|
||||
|
||||
FILENAME.CPP
|
||||
|
||||
Author: Gary Liddon @
|
||||
Created:
|
||||
Project:
|
||||
Purpose:
|
||||
|
||||
Copyright (c) 1998 G R Liddon
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Includes
|
||||
-------- */
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
|
||||
/* Glib
|
||||
---- */
|
||||
#include "pak.h"
|
||||
|
||||
/* Local
|
||||
----- */
|
||||
#include "vimage.h"
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Tyepdefs && Defines
|
||||
------------------- */
|
||||
using namespace std;
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Structure defintions
|
||||
-------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function Prototypes
|
||||
------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Vars
|
||||
---- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Data
|
||||
---- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
VRAMImage::VRAMImage(int NewWidthInTpages,int NewHeightInPixels) : VRAMData(NULL)
|
||||
{
|
||||
WidthInTpages=NewWidthInTpages;
|
||||
HeightInPixels=NewHeightInPixels;
|
||||
HeightInTPages=NewHeightInPixels / 256;
|
||||
|
||||
if (!HeightInTPages)
|
||||
{
|
||||
aTPageHeight = 128;
|
||||
HeightInTPages = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
aTPageHeight = HeightInTPages * 256;
|
||||
}
|
||||
TPageSizeInBytes = 128 * aTPageHeight;
|
||||
|
||||
WidthInBytes=WidthInTpages*128;
|
||||
|
||||
VramAreaBytes=WidthInBytes * HeightInPixels;
|
||||
|
||||
VRAMData=new u8[VramAreaBytes];
|
||||
lbmData = new u8[WidthInTpages*256*HeightInPixels];
|
||||
|
||||
if (!lbmData)
|
||||
Error(ERM_OUTOFMEM);
|
||||
|
||||
if (!VRAMData)
|
||||
Error(ERM_OUTOFMEM);
|
||||
|
||||
memset(VRAMData,0,VramAreaBytes);
|
||||
m_doCompress=false;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
VRAMImage::~VRAMImage(void)
|
||||
{
|
||||
if (lbmData)
|
||||
delete lbmData;
|
||||
if (VRAMData)
|
||||
delete VRAMData;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
void VRAMImage::getTpData(unsigned int tp,std::vector<u8> & dest) const
|
||||
{
|
||||
const int TPAGES_IN_ALL =WidthInTpages * HeightInTPages;
|
||||
|
||||
if (tp >= TPAGES_IN_ALL)
|
||||
Error(ERR_FATAL,"illegal tpage number");
|
||||
|
||||
int tpX,tpY;
|
||||
u8 const * srcTpData;
|
||||
dest.resize(TPageSizeInBytes);
|
||||
|
||||
|
||||
tpX=(tp%WidthInTpages)*128;
|
||||
tpY=(tp/WidthInTpages)*aTPageHeight;
|
||||
|
||||
srcTpData=&VRAMData[tpX+tpY*WidthInBytes];
|
||||
|
||||
for (int x=0;x<128;x++)
|
||||
for (int y=0;y<aTPageHeight;y++)
|
||||
dest[x+y*128]=srcTpData[x+y*WidthInBytes];
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CompressMem(char const * CmdLine,std::vector<u8> & Body)
|
||||
{
|
||||
try
|
||||
{
|
||||
GString Com;
|
||||
|
||||
char TmpName[100];
|
||||
char CompTmpName[100];
|
||||
|
||||
tmpnam(TmpName);
|
||||
tmpnam(CompTmpName);
|
||||
|
||||
GString ComStr(CmdLine);
|
||||
|
||||
ComStr.Replace("%1",TmpName);
|
||||
ComStr.Replace("%2",CompTmpName);
|
||||
|
||||
ofstream Out;
|
||||
Out.open(TmpName,ios::binary|ios::trunc);
|
||||
|
||||
if (Out)
|
||||
{
|
||||
int CompSize;
|
||||
Out.write((char const *)&Body[0],Body.size());
|
||||
Out.close();
|
||||
|
||||
cout<<(char const *)ComStr<<"from "<<CmdLine<<endl;
|
||||
system(ComStr);
|
||||
|
||||
CompSize=FileSize(CompTmpName);
|
||||
|
||||
Body.resize(CompSize);
|
||||
|
||||
ifstream In;
|
||||
In.open(CompTmpName,ios::binary);
|
||||
|
||||
if (In)
|
||||
{
|
||||
In.read((char *)&Body[0],CompSize);
|
||||
In.close();
|
||||
}
|
||||
else
|
||||
throw("Can't open compressed out file");
|
||||
|
||||
}
|
||||
else
|
||||
throw("Can't open uncompressed out file");
|
||||
|
||||
remove(TmpName);
|
||||
remove(CompTmpName);
|
||||
}
|
||||
|
||||
catch (const char * Err)
|
||||
{
|
||||
GObject::Error(ERR_FATAL,"%s im CompressMem",Err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VRAMImage::WriteInTpageChunks(ofstream & str)
|
||||
{
|
||||
const int TPAGES_IN_ALL =WidthInTpages * HeightInTPages;
|
||||
|
||||
vector<u8> tpageData;
|
||||
tpageData.resize(TPageSizeInBytes);
|
||||
|
||||
for (int f=0;f<TPAGES_IN_ALL;f++)
|
||||
{
|
||||
getTpData(f,tpageData);
|
||||
str.write((char*)&tpageData[0],TPageSizeInBytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void VRAMImage::Write(ofstream & Str)
|
||||
{
|
||||
if (m_doCompress)
|
||||
{
|
||||
printf("Packing TPage\n");
|
||||
const int TPAGES_IN_ALL =WidthInTpages * HeightInTPages;
|
||||
const int NUM_OF_WINDOWS = TPAGES_IN_ALL*4;
|
||||
|
||||
vector<u8> tpageData;
|
||||
vector<u8> dataToWrite;
|
||||
|
||||
tpageData.resize(TPageSizeInBytes);
|
||||
dataToWrite.resize(TPageSizeInBytes);
|
||||
|
||||
for (int f=0;f<NUM_OF_WINDOWS;f++)
|
||||
{
|
||||
int dataWriteSize;
|
||||
const u8 * srcData;
|
||||
|
||||
if ((f&3) == 0)
|
||||
getTpData(f/4,tpageData);
|
||||
|
||||
srcData=&tpageData[(f%4)*128*64];
|
||||
|
||||
if (f != 0)
|
||||
{
|
||||
vector<u8> myData;
|
||||
|
||||
myData.resize(128*64);
|
||||
|
||||
memcpy(&myData[0],srcData,128*64);
|
||||
|
||||
#ifdef __USE_LZNP__
|
||||
|
||||
CompressMem("lznp %1 %2",myData);
|
||||
dataWriteSize=myData.size();
|
||||
memcpy(&dataToWrite[0],&myData[0],dataWriteSize);
|
||||
|
||||
#else
|
||||
dataWriteSize=PAK_findPakSize(&myData[0],128*64);
|
||||
PAK_doPak(&dataToWrite[0],&myData[0],128*64);
|
||||
#endif
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
dataWriteSize=128*64;
|
||||
memcpy(&dataToWrite[0],srcData,128*64);
|
||||
}
|
||||
for (int a=0;a<16;a++) printf("%i, ",(int)dataToWrite[a]);
|
||||
printf("\n");
|
||||
Str.write((char *)(&dataToWrite[0]),dataWriteSize);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
Str.write((char *)(VRAMData),VramAreaBytes);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void VRAMImage::PlotPal(SprPal const & PalToPlot)
|
||||
{
|
||||
TPRect Tp=PalToPlot.GetTPRect();
|
||||
|
||||
int W=WidthInTpages*256;
|
||||
|
||||
W/=2;
|
||||
|
||||
u16 * Addr=(u16 *)&VRAMData[Tp.Y*W+Tp.X/2];
|
||||
|
||||
std::vector<u16> OutWords;
|
||||
|
||||
PalToPlot.MakePSXPal(OutWords);
|
||||
|
||||
int f;
|
||||
|
||||
for (f=0;f<OutWords.size();f++)
|
||||
Addr[f]=OutWords[f];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void VRAMImage::PlotFrame(SprFrame const & FrameToPlot)
|
||||
{
|
||||
SprFrame::BDEPTH ThisDepth;
|
||||
|
||||
ThisDepth=FrameToPlot.GetBitDepth();
|
||||
|
||||
switch(ThisDepth)
|
||||
{
|
||||
case SprFrame::BITS_4:
|
||||
PlotFrame4(FrameToPlot);
|
||||
break;
|
||||
|
||||
case SprFrame::BITS_8:
|
||||
PlotFrame8(FrameToPlot);
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
void VRAMImage::SaveAs16ColLbm(const char * Name)
|
||||
{
|
||||
Palette GazPalette;
|
||||
|
||||
GazPalette[0].SetR(0);
|
||||
GazPalette[0].SetG(0);
|
||||
GazPalette[0].SetB(255);
|
||||
|
||||
int W=WidthInTpages*256;
|
||||
int H=HeightInPixels;
|
||||
|
||||
Frame ThisFr;
|
||||
|
||||
for (int f=1;f<15;f++)
|
||||
{
|
||||
int Col=f*17;
|
||||
GazPalette[1+f].SetR(Col);
|
||||
GazPalette[1+f].SetG(Col);
|
||||
GazPalette[1+f].SetB(Col);
|
||||
}
|
||||
|
||||
|
||||
for (int y=0;y<H;y++)
|
||||
for (int x=0;x<W;x++)
|
||||
{
|
||||
if ((x&1))
|
||||
lbmData[x+y*W]=(VRAMData[ (y*(W/2))+(x/2)]&0xf0) >> 4;
|
||||
else
|
||||
lbmData[x+y*W]=VRAMData[(y*(W/2))+(x/2)]&0x0f;
|
||||
}
|
||||
|
||||
ThisFr.SetFrame(lbmData,W,H,GazPalette);
|
||||
ThisFr.SaveLbm(Name);
|
||||
|
||||
cout<<"Written "<<Name<<endl;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void VRAMImage::PlotFrame4(SprFrame const & Fr)
|
||||
{
|
||||
TPRect Tp=Fr.GetTPRect();
|
||||
|
||||
int W=WidthInTpages*256;
|
||||
|
||||
W=W/2; /* we're plotting nibbles */
|
||||
|
||||
if (!Tp.GetRotate())
|
||||
{
|
||||
for (int y=Tp.Y;y<Tp.Y+Tp.H;y++)
|
||||
for (int x=Tp.X;x<Tp.X+Tp.W;x++)
|
||||
{
|
||||
int FrX=x-Tp.X;
|
||||
int FrY=y-Tp.Y;
|
||||
u8 ScrNib=Fr.SeeData()[FrY*Tp.W+FrX]&0xf;
|
||||
u8 * PixAddr=&VRAMData[y*W+x/2];
|
||||
|
||||
if ((x&1))
|
||||
{
|
||||
*PixAddr&=0x0f;
|
||||
*PixAddr|=ScrNib<<4;
|
||||
}
|
||||
else
|
||||
{
|
||||
*PixAddr&=0xf0;
|
||||
*PixAddr|=ScrNib;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int y=Tp.Y;y<Tp.Y+Tp.H;y++)
|
||||
for (int x=Tp.X;x<Tp.X+Tp.W;x++)
|
||||
{
|
||||
int FrX=x-Tp.X;
|
||||
int FrY=y-Tp.Y;
|
||||
|
||||
u8 ScrNib=Fr.SeeData()[FrX*Tp.H+(Tp.H-FrY-1)]&0xf;
|
||||
u8 * PixAddr=&VRAMData[y*W+x/2];
|
||||
|
||||
if ((x&1))
|
||||
{
|
||||
*PixAddr&=0x0f;
|
||||
*PixAddr|=ScrNib<<4;
|
||||
}
|
||||
else
|
||||
{
|
||||
*PixAddr&=0xf0;
|
||||
*PixAddr|=ScrNib;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void VRAMImage::PlotFrame8(SprFrame const & Fr)
|
||||
{
|
||||
const TPRect & Tp=Fr.GetTPRect();
|
||||
|
||||
int W=WidthInTpages*256;
|
||||
|
||||
W/=2;
|
||||
|
||||
u8 * Addr=&VRAMData[Tp.Y*W+Tp.X/2];
|
||||
|
||||
if (!Fr.IsRotated())
|
||||
{
|
||||
for (int y=0;y<Fr.GetHeight();y++)
|
||||
for (int x=0;x<Fr.GetWidth();x++)
|
||||
Addr[y*W+x]=Fr.SeeData()[x+y*Fr.GetWidth()];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
for (int y=0;y<Fr.GetWidth();y++)
|
||||
for (int x=0;x<Fr.GetHeight();x++)
|
||||
Addr[y*W+x]=Fr.SeeData()[x*Fr.GetWidth()+(Fr.GetWidth()-y-1)];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
669
Utils/parkgrab/bmploader.cpp
Normal file
669
Utils/parkgrab/bmploader.cpp
Normal file
|
@ -0,0 +1,669 @@
|
|||
/*=========================================================================
|
||||
|
||||
FILENAME.CPP
|
||||
|
||||
Author: Gary Liddon @
|
||||
Created:
|
||||
Project:
|
||||
Purpose:
|
||||
|
||||
Copyright (c) 1998 G R Liddon
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Includes
|
||||
-------- */
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
|
||||
/* Glib
|
||||
---- */
|
||||
#include <frame.hpp>
|
||||
#include <misc.hpp>
|
||||
|
||||
/* Local
|
||||
----- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Tyepdefs && Defines
|
||||
------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Structure defintions
|
||||
-------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function Prototypes
|
||||
------------------- */
|
||||
using namespace std;
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Vars
|
||||
---- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Data
|
||||
---- */
|
||||
struct RGB
|
||||
{
|
||||
u8 r,g,b;
|
||||
};
|
||||
|
||||
class BITMAP
|
||||
{
|
||||
public:
|
||||
BITMAP(void)
|
||||
{
|
||||
m_width=0;
|
||||
m_height=0;
|
||||
}
|
||||
|
||||
void setSize(int width,int height)
|
||||
{
|
||||
bitMap.resize(width*height);
|
||||
|
||||
m_width=width;
|
||||
m_height=height;
|
||||
}
|
||||
|
||||
void clear(void)
|
||||
{
|
||||
if (m_width && m_height)
|
||||
memset(&bitMap[0],0,m_width*m_height);
|
||||
}
|
||||
|
||||
void line(unsigned int y,unsigned int x,u8 pix)
|
||||
{
|
||||
if (x >= m_width)
|
||||
{
|
||||
GObject::Error(ERR_WARNING,"Out of X boundary - %d %d\n", x, m_width);
|
||||
x = m_width-1;
|
||||
}
|
||||
if (y >= m_height)
|
||||
{
|
||||
GObject::Error(ERR_WARNING,"Out of Y boundary - %d %d\n", y, m_height);
|
||||
y = m_height-1;
|
||||
}
|
||||
bitMap[y*m_width+x]=pix;
|
||||
|
||||
}
|
||||
|
||||
u8 const * getBitMap(void) const
|
||||
{return(&bitMap[0]);}
|
||||
|
||||
protected:
|
||||
int m_width;
|
||||
int m_height;
|
||||
vector<u8> bitMap;
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
|
||||
#define BI_RGB 0
|
||||
#define BI_RLE8 1
|
||||
#define BI_RLE4 2
|
||||
#define BI_BITFIELDS 3
|
||||
|
||||
#define OS2INFOHEADERSIZE 12
|
||||
#define WININFOHEADERSIZE 40
|
||||
|
||||
|
||||
typedef struct BITMAPFILEHEADER
|
||||
{
|
||||
unsigned long bfType;
|
||||
unsigned long bfSize;
|
||||
unsigned short bfReserved1;
|
||||
unsigned short bfReserved2;
|
||||
unsigned long bfOffBits;
|
||||
} BITMAPFILEHEADER;
|
||||
|
||||
|
||||
/* Used for both OS/2 and Windows BMP.
|
||||
* Contains only the parameters needed to load the image
|
||||
*/
|
||||
typedef struct BITMAPINFOHEADER
|
||||
{
|
||||
unsigned long biWidth;
|
||||
unsigned long biHeight;
|
||||
unsigned short biBitCount;
|
||||
unsigned long biCompression;
|
||||
} BITMAPINFOHEADER;
|
||||
|
||||
|
||||
typedef struct WINBMPINFOHEADER /* size: 40 */
|
||||
{
|
||||
unsigned long biWidth;
|
||||
unsigned long biHeight;
|
||||
unsigned short biPlanes;
|
||||
unsigned short biBitCount;
|
||||
unsigned long biCompression;
|
||||
unsigned long biSizeImage;
|
||||
unsigned long biXPelsPerMeter;
|
||||
unsigned long biYPelsPerMeter;
|
||||
unsigned long biClrUsed;
|
||||
unsigned long biClrImportant;
|
||||
} WINBMPINFOHEADER;
|
||||
|
||||
|
||||
typedef struct OS2BMPINFOHEADER /* size: 12 */
|
||||
{
|
||||
unsigned short biWidth;
|
||||
unsigned short biHeight;
|
||||
unsigned short biPlanes;
|
||||
unsigned short biBitCount;
|
||||
} OS2BMPINFOHEADER;
|
||||
|
||||
|
||||
|
||||
/* read_bmfileheader:
|
||||
* Reads a BMP file header and check that it has the BMP magic number.
|
||||
*/
|
||||
static int read_bmfileheader(Gifstream & f, BITMAPFILEHEADER *fileheader)
|
||||
{
|
||||
fileheader->bfType = f.Get16();
|
||||
fileheader->bfSize= f.Get32();
|
||||
fileheader->bfReserved1= f.Get16();
|
||||
fileheader->bfReserved2= f.Get16();
|
||||
fileheader->bfOffBits= f.Get32();
|
||||
|
||||
if (fileheader->bfType != 19778)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* read_win_bminfoheader:
|
||||
* Reads information from a BMP file header.
|
||||
*/
|
||||
static int read_win_bminfoheader(Gifstream & f, BITMAPINFOHEADER *infoheader)
|
||||
{
|
||||
WINBMPINFOHEADER win_infoheader;
|
||||
|
||||
win_infoheader.biWidth = f.Get32();
|
||||
win_infoheader.biHeight = f.Get32();
|
||||
win_infoheader.biPlanes = f.Get16();
|
||||
win_infoheader.biBitCount = f.Get16();
|
||||
win_infoheader.biCompression = f.Get32();
|
||||
win_infoheader.biSizeImage = f.Get32();
|
||||
win_infoheader.biXPelsPerMeter = f.Get32();
|
||||
win_infoheader.biYPelsPerMeter = f.Get32();
|
||||
win_infoheader.biClrUsed = f.Get32();
|
||||
win_infoheader.biClrImportant = f.Get32();
|
||||
|
||||
infoheader->biWidth = win_infoheader.biWidth;
|
||||
infoheader->biHeight = win_infoheader.biHeight;
|
||||
infoheader->biBitCount = win_infoheader.biBitCount;
|
||||
infoheader->biCompression = win_infoheader.biCompression;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* read_os2_bminfoheader:
|
||||
* Reads information from an OS/2 format BMP file header.
|
||||
*/
|
||||
static int read_os2_bminfoheader(Gifstream & f, BITMAPINFOHEADER *infoheader)
|
||||
{
|
||||
OS2BMPINFOHEADER os2_infoheader;
|
||||
|
||||
os2_infoheader.biWidth = f.Get16();
|
||||
os2_infoheader.biHeight = f.Get32();
|
||||
os2_infoheader.biPlanes = f.Get32();
|
||||
os2_infoheader.biBitCount = f.Get32();
|
||||
|
||||
infoheader->biWidth = os2_infoheader.biWidth;
|
||||
infoheader->biHeight = os2_infoheader.biHeight;
|
||||
infoheader->biBitCount = os2_infoheader.biBitCount;
|
||||
infoheader->biCompression = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* read_bmicolors:
|
||||
* Loads the color pallete for 1,4,8 bit formats.
|
||||
*/
|
||||
static void read_bmicolors(int ncols, RGB *pal, Gifstream & f,int win_flag)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<ncols; i++)
|
||||
{
|
||||
pal[i].b = f.get();
|
||||
pal[i].g = f.get();
|
||||
pal[i].r = f.get();
|
||||
|
||||
if (win_flag)
|
||||
f.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* read_1bit_line:
|
||||
* Support function for reading the 1 bit bitmap file format.
|
||||
*/
|
||||
static void read_1bit_line(int length, Gifstream & f, BITMAP *bmp, int line)
|
||||
{
|
||||
unsigned char b[32];
|
||||
unsigned long n;
|
||||
|
||||
int i, j, k;
|
||||
int pix;
|
||||
|
||||
for (i=0; i<length; i++)
|
||||
{
|
||||
j = i % 32;
|
||||
if (j == 0)
|
||||
{
|
||||
n = f.Get32();
|
||||
|
||||
for (k=0; k<32; k++)
|
||||
{
|
||||
b[31-k] = n & 1;
|
||||
n = n >> 1;
|
||||
}
|
||||
}
|
||||
|
||||
pix = b[j];
|
||||
bmp->line(line,i,pix);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* read_4bit_line:
|
||||
* Support function for reading the 4 bit bitmap file format.
|
||||
*/
|
||||
static void read_4bit_line(int length, Gifstream & f, BITMAP *bmp, int line)
|
||||
{
|
||||
unsigned char b[8];
|
||||
unsigned long n;
|
||||
int i, j, k;
|
||||
int temp;
|
||||
int pix;
|
||||
|
||||
for (i=0; i<length; i++)
|
||||
{
|
||||
j = i % 8;
|
||||
if (j == 0)
|
||||
{
|
||||
n = f.Get32();
|
||||
|
||||
for (k=0; k<4; k++)
|
||||
{
|
||||
temp = n & 255;
|
||||
b[k*2+1] = temp & 15;
|
||||
temp = temp >> 4;
|
||||
b[k*2] = temp & 15;
|
||||
n = n >> 8;
|
||||
}
|
||||
}
|
||||
|
||||
pix = b[j];
|
||||
bmp->line(line,i,pix);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* read_8bit_line:
|
||||
* Support function for reading the 8 bit bitmap file format.
|
||||
*/
|
||||
static void read_8bit_line(int length, Gifstream & f, BITMAP *bmp, int line)
|
||||
{
|
||||
unsigned char b[4];
|
||||
unsigned long n;
|
||||
int i, j, k;
|
||||
int pix;
|
||||
|
||||
for (i=0; i<length; i++)
|
||||
{
|
||||
j = i % 4;
|
||||
if (j == 0)
|
||||
{
|
||||
n = f.Get32();
|
||||
for (k=0; k<4; k++)
|
||||
{
|
||||
b[k] = n & 255;
|
||||
n = n >> 8;
|
||||
}
|
||||
}
|
||||
pix = b[j];
|
||||
bmp->line(line,i,pix);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* read_24bit_line:
|
||||
* Support function for reading the 24 bit bitmap file format, doing
|
||||
* our best to convert it down to a 256 color pallete.
|
||||
*/
|
||||
static void read_24bit_line(int length, Gifstream & f, BITMAP *bmp, int line)
|
||||
{
|
||||
#if 0
|
||||
int i, nbytes;
|
||||
RGB c;
|
||||
|
||||
nbytes=0;
|
||||
|
||||
for (i=0; i<length; i++) {
|
||||
c.b = f.get();
|
||||
c.g = f.get();
|
||||
c.r = f.get();
|
||||
bmp->line[line][i*3+_rgb_r_shift_24/8] = c.r;
|
||||
bmp->line[line][i*3+_rgb_g_shift_24/8] = c.g;
|
||||
bmp->line[line][i*3+_rgb_b_shift_24/8] = c.b;
|
||||
nbytes += 3;
|
||||
}
|
||||
|
||||
nbytes = nbytes % 4;
|
||||
if (nbytes != 0)
|
||||
for (i=nbytes; i<4; i++)
|
||||
f.get();;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* read_image:
|
||||
* For reading the noncompressed BMP image format.
|
||||
*/
|
||||
static void read_image(Gifstream & f, BITMAP *bmp, BITMAPINFOHEADER *infoheader)
|
||||
{
|
||||
int i, line;
|
||||
|
||||
for (i=0; i<(int)infoheader->biHeight; i++) {
|
||||
line = i;
|
||||
|
||||
switch (infoheader->biBitCount) {
|
||||
|
||||
case 1:
|
||||
read_1bit_line(infoheader->biWidth, f, bmp, infoheader->biHeight-i-1);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
read_4bit_line(infoheader->biWidth, f, bmp, infoheader->biHeight-i-1);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
read_8bit_line(infoheader->biWidth, f, bmp, infoheader->biHeight-i-1);
|
||||
break;
|
||||
|
||||
case 24:
|
||||
read_24bit_line(infoheader->biWidth, f, bmp, infoheader->biHeight-i-1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* read_RLE8_compressed_image:
|
||||
* For reading the 8 bit RLE compressed BMP image format.
|
||||
*/
|
||||
static void read_RLE8_compressed_image(Gifstream & f, BITMAP *bmp, BITMAPINFOHEADER *infoheader)
|
||||
{
|
||||
unsigned char count, val, val0;
|
||||
int j, pos, line;
|
||||
int eolflag, eopicflag;
|
||||
|
||||
eopicflag = 0;
|
||||
line = infoheader->biHeight - 1;
|
||||
|
||||
while (eopicflag == 0) {
|
||||
pos = 0; /* x position in bitmap */
|
||||
eolflag = 0; /* end of line flag */
|
||||
|
||||
while ((eolflag == 0) && (eopicflag == 0)) {
|
||||
count = f.get();
|
||||
val = f.get();
|
||||
|
||||
if (count > 0) { /* repeat pixel count times */
|
||||
for (j=0;j<count;j++) {
|
||||
bmp->line(line,pos,val);
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (val) {
|
||||
|
||||
case 0: /* end of line flag */
|
||||
eolflag=1;
|
||||
break;
|
||||
|
||||
case 1: /* end of picture flag */
|
||||
eopicflag=1;
|
||||
break;
|
||||
|
||||
case 2: /* displace picture */
|
||||
count = f.get();
|
||||
val = f.get();
|
||||
pos += count;
|
||||
line -= val;
|
||||
break;
|
||||
|
||||
default: /* read in absolute mode */
|
||||
for (j=0; j<val; j++) {
|
||||
val0 = f.get();
|
||||
bmp->line(line,pos,val0);
|
||||
pos++;
|
||||
}
|
||||
|
||||
if (j%2 == 1)
|
||||
val0 = f.get(); /* align on word boundary */
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (pos > (int)infoheader->biWidth)
|
||||
eolflag=1;
|
||||
}
|
||||
|
||||
line--;
|
||||
if (line < 0)
|
||||
eopicflag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* read_RLE4_compressed_image:
|
||||
* For reading the 4 bit RLE compressed BMP image format.
|
||||
*/
|
||||
static void read_RLE4_compressed_image(Gifstream & f, BITMAP *bmp, BITMAPINFOHEADER *infoheader)
|
||||
{
|
||||
unsigned char b[8];
|
||||
unsigned char count;
|
||||
unsigned short val0, val;
|
||||
int j, k, pos, line;
|
||||
int eolflag, eopicflag;
|
||||
|
||||
eopicflag = 0; /* end of picture flag */
|
||||
line = infoheader->biHeight - 1;
|
||||
|
||||
while (eopicflag == 0) {
|
||||
pos = 0;
|
||||
eolflag = 0; /* end of line flag */
|
||||
|
||||
while ((eolflag == 0) && (eopicflag == 0)) {
|
||||
count = f.get();
|
||||
val = f.get();
|
||||
|
||||
if (count > 0) { /* repeat pixels count times */
|
||||
b[1] = val & 15;
|
||||
b[0] = (val >> 4) & 15;
|
||||
for (j=0; j<count; j++) {
|
||||
bmp->line(line,pos,b[j%2]);
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (val) {
|
||||
|
||||
case 0: /* end of line */
|
||||
eolflag=1;
|
||||
break;
|
||||
|
||||
case 1: /* end of picture */
|
||||
eopicflag=1;
|
||||
break;
|
||||
|
||||
case 2: /* displace image */
|
||||
count = f.get();
|
||||
val = f.get();
|
||||
pos += count;
|
||||
line -= val;
|
||||
break;
|
||||
|
||||
default: /* read in absolute mode */
|
||||
for (j=0; j<val; j++) {
|
||||
if ((j%4) == 0) {
|
||||
val0 = f.Get16();
|
||||
for (k=0; k<2; k++) {
|
||||
b[2*k+1] = val0 & 15;
|
||||
val0 = val0 >> 4;
|
||||
b[2*k] = val0 & 15;
|
||||
val0 = val0 >> 4;
|
||||
}
|
||||
}
|
||||
bmp->line(line,pos,b[j%4]);
|
||||
pos++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pos > (int)infoheader->biWidth)
|
||||
eolflag=1;
|
||||
}
|
||||
|
||||
line--;
|
||||
if (line < 0)
|
||||
eopicflag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* load_bmp:
|
||||
* Loads a Windows BMP file, returning a bitmap structure and storing
|
||||
* the pallete data in the specified pallete (this should be an array of
|
||||
* at least 256 RGB structures).
|
||||
*
|
||||
* Thanks to Seymour Shlien for contributing this function.
|
||||
*/
|
||||
|
||||
void load_bmp(Frame & frm,char const *filename)
|
||||
{
|
||||
BITMAPFILEHEADER fileheader;
|
||||
BITMAPINFOHEADER infoheader;
|
||||
|
||||
RGB pal[256];
|
||||
BITMAP bmp;
|
||||
|
||||
Gifstream f(Gifstream::LITTLE_ENDIAN);
|
||||
|
||||
int ncol;
|
||||
unsigned long biSize;
|
||||
|
||||
f.open(filename,ios::in|ios::binary);
|
||||
|
||||
if (!f)
|
||||
GObject::Error(ERR_FATAL,"couldn't open file %s",filename);
|
||||
|
||||
if (read_bmfileheader(f, &fileheader) != 0)
|
||||
{
|
||||
GObject::Error(ERR_FATAL,"error reading bmp hdr for %s",filename);
|
||||
}
|
||||
|
||||
biSize = f.Get32();
|
||||
|
||||
if (biSize == WININFOHEADERSIZE)
|
||||
{
|
||||
if (read_win_bminfoheader(f, &infoheader) != 0)
|
||||
GObject::Error(ERR_FATAL,"error reading windows bmp info hdr for %s",filename);
|
||||
|
||||
/* compute number of colors recorded */
|
||||
ncol = (fileheader.bfOffBits - 54) / 4;
|
||||
read_bmicolors(ncol, pal, f, 1);
|
||||
}
|
||||
else if (biSize == OS2INFOHEADERSIZE)
|
||||
{
|
||||
if (read_os2_bminfoheader(f, &infoheader) != 0)
|
||||
GObject::Error(ERR_FATAL,"error reading os2 bmp info hdr for %s",filename);
|
||||
|
||||
/* compute number of colors recorded */
|
||||
ncol = (fileheader.bfOffBits - 26) / 3;
|
||||
read_bmicolors(ncol, pal, f, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
GObject::Error(ERR_FATAL,"error finding correct hdr for bmp %s",filename);
|
||||
}
|
||||
|
||||
if (infoheader.biBitCount != 4 && infoheader.biBitCount != 8)
|
||||
GObject::Error(ERR_FATAL,"only handles 4 && 8 bit bmps not %d : %s",infoheader.biBitCount,filename);
|
||||
|
||||
|
||||
bmp.setSize(infoheader.biWidth, infoheader.biHeight);
|
||||
|
||||
bmp.clear();
|
||||
|
||||
switch (infoheader.biCompression)
|
||||
{
|
||||
|
||||
case BI_RGB:
|
||||
read_image(f, &bmp, &infoheader);
|
||||
break;
|
||||
|
||||
case BI_RLE8:
|
||||
read_RLE8_compressed_image(f, &bmp, &infoheader);
|
||||
break;
|
||||
|
||||
case BI_RLE4:
|
||||
read_RLE4_compressed_image(f, &bmp, &infoheader);
|
||||
break;
|
||||
|
||||
default:
|
||||
GObject::Error(ERR_FATAL,"unknown compression foramt for %s",filename);
|
||||
break;
|
||||
}
|
||||
|
||||
f.close();
|
||||
|
||||
|
||||
{
|
||||
Palette palObj;
|
||||
|
||||
|
||||
|
||||
for (int f=0;f<ncol;f++)
|
||||
{
|
||||
Colour & col = palObj[f];
|
||||
col.SetRGB(pal[f].r,pal[f].g,pal[f].b);
|
||||
}
|
||||
|
||||
frm.SetFrame(bmp.getBitMap(),infoheader.biWidth,infoheader.biHeight,palObj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
58
Utils/parkgrab/bmploader.h
Normal file
58
Utils/parkgrab/bmploader.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*=========================================================================
|
||||
|
||||
FILENAME.CPP
|
||||
|
||||
Author: Gary Liddon @
|
||||
Created:
|
||||
Project:
|
||||
Purpose:
|
||||
|
||||
Copyright (c) 1998 G R Liddon
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
#ifndef __BMPLOADER_H__
|
||||
#define __BMPLOADER_H__
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Includes
|
||||
-------- */
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
|
||||
/* Glib
|
||||
---- */
|
||||
#include <frame.hpp>
|
||||
|
||||
/* Local
|
||||
----- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Tyepdefs && Defines
|
||||
------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Structure defintions
|
||||
-------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Globals
|
||||
------- */
|
||||
|
||||
/* Vars
|
||||
---- */
|
||||
|
||||
/* Data
|
||||
---- */
|
||||
|
||||
/* Functions
|
||||
--------- */
|
||||
void load_bmp(Frame & frm,char const *filename);
|
||||
|
||||
/*---------------------------------------------------------------------- */
|
||||
|
||||
#endif /* __BMPLOADER_H__ */
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
158
Utils/parkgrab/cross.cpp
Normal file
158
Utils/parkgrab/cross.cpp
Normal file
|
@ -0,0 +1,158 @@
|
|||
/*=========================================================================
|
||||
|
||||
CROSS.CPP
|
||||
|
||||
Author: Gary Liddon @ Climax
|
||||
Created:
|
||||
Project: Diablo Playstation Conversion
|
||||
Purpose: Find A Crosshair on a frame
|
||||
|
||||
Copyright (c) 1996 Director's Cut Ltd.
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Includes
|
||||
-------- */
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
|
||||
/* STL
|
||||
--- */
|
||||
|
||||
/* Glib
|
||||
---- */
|
||||
|
||||
/* Local
|
||||
----- */
|
||||
#include "cross.h"
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Structure defintions
|
||||
-------------------- */
|
||||
using namespace std;
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Tyepdefs && Defines
|
||||
------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function Prototypes
|
||||
------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Vars
|
||||
---- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Classes
|
||||
------- */
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Description:
|
||||
Find a cross hair in this frame for animation offset and store it
|
||||
into member vars x and y.
|
||||
|
||||
Returns:
|
||||
True if a cross hair is found
|
||||
---------------------------------------------------------------------- */
|
||||
bool CROSS_RES::FindCrossHair(
|
||||
Frame const & Fr, /* Frame we're looking for a cross-hair in */
|
||||
u8 CrossCol /* Pixel value of cross hair we're looking for */
|
||||
)
|
||||
{
|
||||
u8 const * FrmData;
|
||||
int * CountCol=NULL;
|
||||
int * CountRow=NULL;
|
||||
|
||||
int Width;
|
||||
int Height;
|
||||
bool RetVal;
|
||||
|
||||
RetVal=false;
|
||||
|
||||
Width=Fr.GetWidth();
|
||||
Height=Fr.GetHeight();
|
||||
|
||||
if (Width && Height)
|
||||
{
|
||||
int Col;
|
||||
int Row;
|
||||
|
||||
if (!(CountCol=new int[Width]))
|
||||
{
|
||||
cout<<"Width is "<<Width<<endl;
|
||||
GObject::Error(ERM_OUTOFMEM);
|
||||
}
|
||||
|
||||
if (!(CountRow=new int[Height]))
|
||||
{
|
||||
cout<<"Height is "<<Width<<endl;
|
||||
GObject::Error(ERM_OUTOFMEM);
|
||||
}
|
||||
|
||||
memset(CountRow,0,sizeof(int)*Height);
|
||||
memset(CountCol,0,sizeof(int)*Width);
|
||||
|
||||
FrmData=Fr.SeeData();
|
||||
|
||||
for (int yy=0;yy<Height;yy++)
|
||||
{
|
||||
u8 const * ThisRow=&FrmData[yy*Width];
|
||||
|
||||
for (int xx=0;xx<Width;xx++)
|
||||
{
|
||||
if (ThisRow[xx] == CrossCol)
|
||||
{
|
||||
CountRow[yy]++;
|
||||
CountCol[xx]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Col=FindLargestIndex(CountCol,Width);
|
||||
Row=FindLargestIndex(CountRow,Height);
|
||||
|
||||
if ((Col != -1) && (Row != -1))
|
||||
{
|
||||
x=Col;
|
||||
y=Row;
|
||||
RetVal=true;
|
||||
}
|
||||
}
|
||||
|
||||
if (CountCol)
|
||||
delete CountCol;
|
||||
|
||||
if (CountRow)
|
||||
delete CountRow;
|
||||
|
||||
return(RetVal);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Description:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
int CROSS_RES::FindLargestIndex(int * CountCol,int Width)
|
||||
{
|
||||
int LargestIndex=-1;
|
||||
int Largest=0;
|
||||
|
||||
for (int f=0;f<Width;f++)
|
||||
{
|
||||
if (CountCol[f] > Largest)
|
||||
{
|
||||
Largest=CountCol[f];
|
||||
LargestIndex=f;
|
||||
}
|
||||
}
|
||||
|
||||
return(LargestIndex);
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
||||
|
67
Utils/parkgrab/cross.h
Normal file
67
Utils/parkgrab/cross.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*=========================================================================
|
||||
|
||||
CROSS.CPP
|
||||
|
||||
Author: Gary Liddon @ Climax
|
||||
Created:
|
||||
Project: Diablo Playstation Conversion
|
||||
Purpose: Find A Crosshair on a frame
|
||||
|
||||
Copyright (c) 1996 Director's Cut Ltd.
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
#ifndef __CROSS_HPP__
|
||||
#define __CROSS_HPP__
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Includes
|
||||
-------- */
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
|
||||
/* STL
|
||||
--- */
|
||||
|
||||
/* Glib
|
||||
---- */
|
||||
#include <gobject.hpp>
|
||||
#include <frame.hpp>
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Tyepdefs && Defines
|
||||
------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Description:
|
||||
This structure is used to find centering cross hairs
|
||||
in frame objects using the FindCrossHair method.
|
||||
If a cross hair is found, the results are put in
|
||||
the x and y member vars.
|
||||
---------------------------------------------------------------------- */
|
||||
struct CROSS_RES
|
||||
{
|
||||
int x; /* x co-ord of cross found */
|
||||
int y; /* y co-ord of cross found */
|
||||
|
||||
bool FindCrossHair(Frame const & Fr,u8 CrossCol);
|
||||
|
||||
private:
|
||||
int FindLargestIndex(int * CountCol,int Width);
|
||||
};
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function Prototypes
|
||||
------------------- */
|
||||
|
||||
/*---------------------------------------------------------------------- */
|
||||
|
||||
#endif /* __CROSS_HPP__ */
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
||||
|
||||
|
138
Utils/parkgrab/grect.cpp
Normal file
138
Utils/parkgrab/grect.cpp
Normal file
|
@ -0,0 +1,138 @@
|
|||
/*=========================================================================
|
||||
|
||||
GRECT.CPP
|
||||
|
||||
Author: Gary Liddon @ Climax
|
||||
Created:
|
||||
Project:
|
||||
Purpose:
|
||||
|
||||
Copyright (c) 1997 Climax Development Ltd
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Includes
|
||||
-------- */
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
#include <algorithm>
|
||||
|
||||
/* Glib
|
||||
---- */
|
||||
#include <frame.hpp>
|
||||
|
||||
/* Local
|
||||
----- */
|
||||
#include "grect.h"
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Tyepdefs && Defines
|
||||
------------------- */
|
||||
using namespace std;
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Structure defintions
|
||||
-------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Positional Vars
|
||||
--------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function Prototypes
|
||||
------------------- */
|
||||
static Rect & AddAnotherRect(RectVec & Result);
|
||||
static void AddRectMessage(Rect const & T);
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Vars
|
||||
---- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Data
|
||||
---- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
Rect & AddAnotherRect(RectVec & Result)
|
||||
{
|
||||
Result.resize(Result.size()+1);
|
||||
return(Result[Result.size()-1]);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
void CutRect(Rect const & ToBeCut,Rect const & TheCutter,RectVec & Result)
|
||||
{
|
||||
Rect Cutter=TheCutter;
|
||||
|
||||
ToBeCut.ClipRect(Cutter);
|
||||
|
||||
if (Cutter)
|
||||
{
|
||||
/* Is there a top rectangle hanging about? */
|
||||
|
||||
if (ToBeCut.Y != Cutter.Y)
|
||||
{
|
||||
Rect & TopRect=AddAnotherRect(Result);
|
||||
TopRect=ToBeCut;
|
||||
TopRect.H=Cutter.Y-TopRect.Y;
|
||||
AddRectMessage(TopRect);
|
||||
}
|
||||
|
||||
/* Is there a bottom rectangle hanging about? */
|
||||
|
||||
if ((ToBeCut.Y+ToBeCut.H) != (Cutter.Y+Cutter.H))
|
||||
{
|
||||
Rect & TopRect=AddAnotherRect(Result);
|
||||
TopRect=ToBeCut;
|
||||
TopRect.Y=Cutter.Y+Cutter.H;
|
||||
TopRect.H=(ToBeCut.Y+ToBeCut.H)-(Cutter.Y+Cutter.H);
|
||||
AddRectMessage(TopRect);
|
||||
}
|
||||
|
||||
/* Is there a left rectangle hanging about? */
|
||||
|
||||
if (ToBeCut.X != Cutter.X)
|
||||
{
|
||||
Rect & TopRect=AddAnotherRect(Result);
|
||||
TopRect=Cutter;
|
||||
TopRect.X=ToBeCut.X;
|
||||
TopRect.W=Cutter.X-ToBeCut.X;
|
||||
AddRectMessage(TopRect);
|
||||
}
|
||||
|
||||
/* Is there a right rectangle hanging about? */
|
||||
|
||||
if ((ToBeCut.X+ToBeCut.W) != (Cutter.X+Cutter.W))
|
||||
{
|
||||
Rect & TopRect=AddAnotherRect(Result);
|
||||
TopRect=Cutter;
|
||||
TopRect.X=Cutter.X+Cutter.W;
|
||||
TopRect.W=(ToBeCut.X+ToBeCut.W)-(Cutter.X+Cutter.W);
|
||||
AddRectMessage(TopRect);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AddRectMessage(Rect const & T)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
63
Utils/parkgrab/grect.h
Normal file
63
Utils/parkgrab/grect.h
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*=========================================================================
|
||||
|
||||
GRECT.CPP
|
||||
|
||||
Author: Gary Liddon @ Climax
|
||||
Created:
|
||||
Project:
|
||||
Purpose:
|
||||
|
||||
Copyright (c) 1997 Climax Development Ltd
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
#ifndef __GRECT_H__
|
||||
#define __GRECT_H__
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Includes
|
||||
-------- */
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
#include <vector>
|
||||
|
||||
/* Glib
|
||||
---- */
|
||||
#include <frame.hpp>
|
||||
|
||||
/* Local
|
||||
----- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Tyepdefs && Defines
|
||||
------------------- */
|
||||
|
||||
typedef std::vector<Rect> RectVec;
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Structure defintions
|
||||
-------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Globals
|
||||
------- */
|
||||
|
||||
/* Vars
|
||||
---- */
|
||||
|
||||
/* Data
|
||||
---- */
|
||||
|
||||
/* Functions
|
||||
--------- */
|
||||
void CutRect(Rect const & ToBeCut,Rect const & TheCutter,RectVec & Result);
|
||||
void ReportRectVec(RectVec & Result);
|
||||
void GRectTest(void);
|
||||
|
||||
/*---------------------------------------------------------------------- */
|
||||
|
||||
#endif /* __GRECT_H__ */
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
703
Utils/parkgrab/main.cpp
Normal file
703
Utils/parkgrab/main.cpp
Normal file
|
@ -0,0 +1,703 @@
|
|||
/*=========================================================================
|
||||
|
||||
MAIN.CPP
|
||||
|
||||
Author: Gary Liddon @ Fareham
|
||||
Created: 28th September 1998
|
||||
Project: Theme Park World PSX
|
||||
Purpose: Main file for tpw sprite grabber (it's sprgrab II!)
|
||||
|
||||
Copyright (c) 1998 G R Liddon
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Version info
|
||||
|
||||
1.0 - 1.1 Various changes by various authors
|
||||
1.2 GL Added -r switch to allow \ disallow sprite rotation
|
||||
1.3 GL Added -x option to allow saving out of non VRAM sprs
|
||||
1.31 GL Added -f option so you can force offsets to a value
|
||||
1.4 TS Added replacement of bad characters in filenames
|
||||
1.5 GL Added support for BMP files
|
||||
1.6 GL Made all out files lower case
|
||||
Checked for errrors when writing files (Doh!)
|
||||
1.7 GL Added -q (turn on\of grabbers shrink to fit routine)
|
||||
Also Added -k option to report where each texture has gone in the VRAM,
|
||||
This will be read by mikes gin -> ars program for deciding what to do about shared
|
||||
textures
|
||||
1.71 GL Added widths and heights of textures to report file
|
||||
1.72 GL Actually made the -q switch do what it was supposed to. Doh!
|
||||
1.8 GL Added -i switch to set output dir for inc files
|
||||
1.81 GL Corrected bug in 1.8 that meant no .h was written
|
||||
1.9 GL -e to set maximum size for textures
|
||||
1.91 GL Changed so that files prefixed with a "+" have col zero as see-through
|
||||
2.0 GL Added reading of gin files and import of rep files
|
||||
2.1 GL Added spare tpage space defintions
|
||||
2.11 GL Added the rather excellent -j option
|
||||
2.12 GL Fixed a bug, stopped -j textures from being reduced
|
||||
2.13 GL Removed the -j option and changed it so that all textures starting with ! are auto -j'd ;)
|
||||
2.14 GL Replaced bit map loader, will move this code into Frame at some point
|
||||
2.15 GL Restricted it so that only images up to 254x254 are allowed
|
||||
2.16 GL Fixed bug that meant 256 col images were often shagged
|
||||
2.17 TS Added '@' filename pre-fix to denote scrolling and transparent textures
|
||||
2.2 GL Changed the autocropping so that if the image is blank it allocates a 1x1 texture instead of a
|
||||
texture the size of the input lbm
|
||||
2.21 GL added -twisting_my_melon_man siwtch (don't ask)
|
||||
2.3 GL added -y command to give us tpage compression
|
||||
2.31 GL -y didn't work (not even a little bit) but it does now ;)
|
||||
2.4 GL Added -~ switch to write out a raw tpage chunked version of the VRAM file
|
||||
2.41 GL Added -^ switch to stop any tpages being written
|
||||
2.5 TS Added -h half a tpage flag
|
||||
2.6 DO Added -w only output animated texture frame headers
|
||||
Added -b dont output spare boxes
|
||||
Added -a align headers to 2k
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Includes
|
||||
-------- */
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
#include <vector>
|
||||
#include <conio.h>
|
||||
|
||||
/* Glib
|
||||
---- */
|
||||
#include <gtypes.h>
|
||||
#include <gstring.hpp>
|
||||
#include <misc.hpp>
|
||||
#include <gfname.hpp>
|
||||
#include <pcre.h>
|
||||
|
||||
/* TP Lib
|
||||
------- */
|
||||
#include <ginio.h>
|
||||
#include <repread.h>
|
||||
|
||||
|
||||
/* Local
|
||||
----- */
|
||||
#include "sprset.h"
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Tyepdefs && Defines
|
||||
------------------- */
|
||||
using namespace std;
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Class defintions
|
||||
---------------- */
|
||||
|
||||
/* Hold's a list of all the files to be processed on along with the options that apply to them
|
||||
------------------------------------------------------------------------------------------- */
|
||||
class AllFiles : protected FileCycler
|
||||
{
|
||||
public:
|
||||
AllFiles(void)
|
||||
{
|
||||
RecurseFiles=false;
|
||||
CrossHair=false;
|
||||
ZeroColZero=false;
|
||||
MoveUVs=false;
|
||||
AllowRotate=true;
|
||||
ForceOffsets=false;
|
||||
ShrinkToFit=true;
|
||||
m_allocateAs16bit=false;
|
||||
MaxSize=0;
|
||||
m_noSort=false;
|
||||
}
|
||||
|
||||
void SetFileRecursion(bool NewRecurseFiles)
|
||||
{RecurseFiles=NewRecurseFiles;}
|
||||
|
||||
void SetCrossHair(bool NewCrossHair)
|
||||
{CrossHair=NewCrossHair;}
|
||||
|
||||
void SetZeroColZero(bool NewColZero)
|
||||
{ZeroColZero=NewColZero;}
|
||||
|
||||
void SetMoveUVs(bool NewMoveUVs)
|
||||
{MoveUVs=NewMoveUVs;}
|
||||
|
||||
void SetAllowRotate(bool NewAllowRotate)
|
||||
{AllowRotate=NewAllowRotate;}
|
||||
|
||||
void SetForceOffsets(bool NewForceOffsets)
|
||||
{ForceOffsets=NewForceOffsets;}
|
||||
|
||||
void SetShrinkToFit(bool NewSetShrinkToFit)
|
||||
{ShrinkToFit=NewSetShrinkToFit;}
|
||||
|
||||
void SetXOff(int NewXOff)
|
||||
{XOff=NewXOff;}
|
||||
|
||||
void SetYOff(int NewYOff)
|
||||
{YOff=NewYOff;}
|
||||
|
||||
void SetMaxSize(int New)
|
||||
{MaxSize=New;}
|
||||
|
||||
int GetMaxSize(void) const
|
||||
{return(MaxSize);}
|
||||
|
||||
void AddFile(const char * Name);
|
||||
|
||||
FIVec const & GetFileInfoVector(void) const
|
||||
{return(AllFileInfos);}
|
||||
|
||||
void SortOrder();
|
||||
|
||||
void ReadRepFile(char const * Name)
|
||||
{
|
||||
vector<RepItem> MyItems;
|
||||
|
||||
::readRepFile(Name,MyItems);
|
||||
|
||||
for (int f=0;f<MyItems.size();f++)
|
||||
AllExternalSharedTextures.push_back(MyItems[f].m_texName);
|
||||
|
||||
cout<<"Read report file "<<Name<<endl;
|
||||
}
|
||||
|
||||
void setAllocateAs16Bit(bool newVal)
|
||||
{m_allocateAs16bit=newVal;}
|
||||
|
||||
void setNoSort(void)
|
||||
{
|
||||
m_noSort=true;
|
||||
}
|
||||
|
||||
protected:
|
||||
vector<GString> UniqueTexturesSoFar;
|
||||
vector<GString> AllExternalSharedTextures;
|
||||
|
||||
void FileCallback(char const * FName,int FileNum);
|
||||
|
||||
bool ShrinkToFit;
|
||||
bool RecurseFiles;
|
||||
bool CrossHair;
|
||||
bool ZeroColZero;
|
||||
bool MoveUVs;
|
||||
bool AllowRotate;
|
||||
bool ForceOffsets;
|
||||
|
||||
bool m_allocateAs16bit;
|
||||
bool m_noSort;
|
||||
|
||||
int XOff,YOff;
|
||||
|
||||
FIVec AllFileInfos;
|
||||
int MaxSize;
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function Prototypes
|
||||
------------------- */
|
||||
static char * CycleCommands(char *String,int Num);
|
||||
static void Usage(void);
|
||||
static bool CheckPlusMinus(const char * Str);
|
||||
static GString CheckFileString(const char * Str);
|
||||
static GString OutFile;
|
||||
static GString OutLbm;
|
||||
static GString SprFile;
|
||||
static GString ReportFile;
|
||||
static GString IncOutFile;
|
||||
|
||||
static int PageBase;
|
||||
static int WidthPages;
|
||||
static int HeightPages;
|
||||
static bool PagePlacements=false;
|
||||
static bool s_compressTpages=false;
|
||||
static bool s_noWriteTpages=false;
|
||||
static bool s_useHalfTpage=false;
|
||||
static bool s_AnimatedHeadersOnly=false;
|
||||
static bool s_DontOutputBoxes=false;
|
||||
static bool s_AlignHeaders=false;
|
||||
|
||||
static GString s_rawTpageFile;
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Vars
|
||||
---- */
|
||||
static AllFiles MyFiles;
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Data
|
||||
---- */
|
||||
|
||||
static const float Version = 2.6;
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
int main(int argc,char ** argv)
|
||||
{
|
||||
cerr<<"GRLiddon() PARKGRAB TPW Spr Grabber "<<Version<<endl;
|
||||
cerr<<"Copyright (c) 1998/1999G R Liddon. All rights reserved"<<endl<<endl;
|
||||
|
||||
if (argc==1)
|
||||
Usage();
|
||||
else
|
||||
{
|
||||
/* TODO:
|
||||
Don't like this command line stuff, will change in glib at some point
|
||||
*/
|
||||
|
||||
CommandLine(argc,argv,CycleCommands);
|
||||
|
||||
SprSet MySprSet;
|
||||
|
||||
MySprSet.setHalfTpage(s_useHalfTpage);
|
||||
MySprSet.setAnimatedHeader(s_AnimatedHeadersOnly);
|
||||
MySprSet.setDontOutputBoxes(s_DontOutputBoxes);
|
||||
MySprSet.setAlignHeaders(s_AlignHeaders);
|
||||
MySprSet.setCompressTpages(s_compressTpages);
|
||||
MySprSet.setNoWriteTpages(s_noWriteTpages);
|
||||
|
||||
MyFiles.SortOrder();
|
||||
|
||||
if (MyFiles.GetMaxSize())
|
||||
MySprSet.SetMaxSize(MyFiles.GetMaxSize());
|
||||
|
||||
MySprSet.AddFiles(MyFiles.GetFileInfoVector());
|
||||
|
||||
if (IncOutFile)
|
||||
MySprSet.SetIncOutFile(IncOutFile);
|
||||
|
||||
if (SprFile)
|
||||
MySprSet.WriteSprFile(SprFile);
|
||||
|
||||
if (OutFile)
|
||||
{
|
||||
if (PagePlacements)
|
||||
{
|
||||
MySprSet.Write(OutFile,PageBase,WidthPages,HeightPages);
|
||||
|
||||
if (OutLbm)
|
||||
MySprSet.WriteLBM(OutLbm);
|
||||
|
||||
if (ReportFile)
|
||||
MySprSet.WriteReport(ReportFile);
|
||||
|
||||
if (s_rawTpageFile)
|
||||
MySprSet.writeRawTPage(s_rawTpageFile);
|
||||
|
||||
}
|
||||
else
|
||||
GObject::Error(ERR_FATAL,"-t option hasn't been specified");
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function: int CountCommas(char const * Str)
|
||||
Purpose: Count how many commas there are in this str
|
||||
Returns: Number of commas
|
||||
---------------------------------------------------------------------- */
|
||||
int CountCommas(char const * Str)
|
||||
{
|
||||
int Len=strlen(Str);
|
||||
int NumOfCommas=0;
|
||||
|
||||
for (int f=0;f<Len;f++)
|
||||
{
|
||||
if (Str[f]==',')
|
||||
NumOfCommas++;
|
||||
}
|
||||
|
||||
return(NumOfCommas);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function: int ZeroAndCountCommas(char * Str)
|
||||
Purpose: Count how many commas there are in this str
|
||||
and change each one to a zero
|
||||
Returns: Number of commas
|
||||
---------------------------------------------------------------------- */
|
||||
int ZeroAndCountCommas(char * Str)
|
||||
{
|
||||
int Len=strlen(Str);
|
||||
int NumOfCommas=0;
|
||||
|
||||
for (int f=0;f<Len;f++)
|
||||
{
|
||||
if (Str[f]==',')
|
||||
{
|
||||
NumOfCommas++;
|
||||
Str[f]=0;
|
||||
}
|
||||
}
|
||||
|
||||
return(NumOfCommas);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function: char *CycleCommands(char *String,int Num)
|
||||
Purpose: Callback to cycle through command line items
|
||||
Params: String = Text of item
|
||||
Num = Item number
|
||||
---------------------------------------------------------------------- */
|
||||
char * CycleCommands(char *String,int Num)
|
||||
{
|
||||
if (GString(String)=="-twisting_my_melon_man")
|
||||
{
|
||||
MyFiles.setNoSort();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (String[0]=='-' || String[0]=='/')
|
||||
{
|
||||
int NumOfCommas;
|
||||
char TpText[100];
|
||||
GString TpStr;
|
||||
char * MyText;
|
||||
|
||||
switch (String[1])
|
||||
{
|
||||
/* Switches */
|
||||
case 'w':
|
||||
s_AnimatedHeadersOnly=CheckPlusMinus(String);
|
||||
break;
|
||||
case 'b':
|
||||
s_DontOutputBoxes=CheckPlusMinus(String);
|
||||
break;
|
||||
case 'a':
|
||||
s_AlignHeaders=CheckPlusMinus(String);
|
||||
break;
|
||||
case 'h':
|
||||
s_useHalfTpage=CheckPlusMinus(String);
|
||||
break;
|
||||
case 'y':
|
||||
s_compressTpages=CheckPlusMinus(String);
|
||||
break;
|
||||
|
||||
case '^':
|
||||
s_noWriteTpages=CheckPlusMinus(String);
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
MyFiles.ReadRepFile(CheckFileString(String));
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
MyFiles.SetAllowRotate(CheckPlusMinus(String));
|
||||
break;
|
||||
|
||||
case 's':
|
||||
MyFiles.SetFileRecursion(CheckPlusMinus(String));
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
MyFiles.SetCrossHair(CheckPlusMinus(String));
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
MyFiles.SetZeroColZero(CheckPlusMinus(String));
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
MyFiles.SetMoveUVs(CheckPlusMinus(String));
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
MyFiles.SetShrinkToFit(CheckPlusMinus(String));
|
||||
break;
|
||||
|
||||
/* Options that set output files */
|
||||
|
||||
case 'o':
|
||||
OutFile=CheckFileString(String);
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
SprFile=CheckFileString(String);
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
OutLbm=CheckFileString(String);
|
||||
break;
|
||||
|
||||
case 'k':
|
||||
ReportFile=CheckFileString(String);
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
IncOutFile=CheckFileString(String);
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
{
|
||||
GString MaxSize;
|
||||
MaxSize=CheckFileString(String);
|
||||
MyFiles.SetMaxSize(atoi(MaxSize));
|
||||
}
|
||||
break;
|
||||
|
||||
/* More complex options */
|
||||
|
||||
case 't':
|
||||
TpStr=CheckFileString(String);
|
||||
|
||||
strcpy(TpText,TpStr);
|
||||
|
||||
NumOfCommas=ZeroAndCountCommas(TpText);
|
||||
|
||||
if (NumOfCommas != 2)
|
||||
GObject::Error(ERR_FATAL,"Problem with option %s",String);
|
||||
|
||||
MyText=TpText;
|
||||
|
||||
PageBase=atoi(MyText);
|
||||
MyText+=strlen(MyText)+1;
|
||||
|
||||
WidthPages=atoi(MyText);
|
||||
MyText+=strlen(MyText)+1;
|
||||
|
||||
HeightPages=atoi(MyText);
|
||||
|
||||
PagePlacements=true;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
TpStr=CheckFileString(String);
|
||||
|
||||
strcpy(TpText,TpStr);
|
||||
|
||||
NumOfCommas=ZeroAndCountCommas(TpText);
|
||||
|
||||
if (NumOfCommas != 1)
|
||||
GObject::Error(ERR_FATAL,"Problem with option %s",String);
|
||||
|
||||
MyText=TpText;
|
||||
|
||||
MyFiles.SetXOff(atoi(MyText));
|
||||
MyText+=strlen(MyText)+1;
|
||||
|
||||
MyFiles.SetYOff(atoi(MyText));
|
||||
MyText+=strlen(MyText)+1;
|
||||
|
||||
MyFiles.SetForceOffsets(true);;
|
||||
break;
|
||||
|
||||
case '~':
|
||||
s_rawTpageFile=CheckFileString(String);
|
||||
break;
|
||||
|
||||
default:
|
||||
GObject::Error(ERR_FATAL,"Unknown switch %s",String);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GString UpperName(String);
|
||||
UpperName.Upper();
|
||||
MyFiles.AddFile(UpperName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return(String);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function: void CheckPlusMinus(const char * Str)
|
||||
Purpose: Check to see if this cmd line item is of the type
|
||||
-<char>+|-. Aborts out of there was a problem.
|
||||
Params: Str = Text of item
|
||||
Returns: true if a plus option
|
||||
---------------------------------------------------------------------- */
|
||||
bool CheckPlusMinus(const char * Str)
|
||||
{
|
||||
if (strlen(Str)==3 && (Str[0]=='-' || Str[0]=='/') && (Str[2]=='-' || Str[2]=='+'))
|
||||
{
|
||||
}
|
||||
else
|
||||
GObject::Error(ERR_FATAL,"Problem with cmd line option %s",Str);
|
||||
|
||||
return(Str[2]=='+');
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function: void CheckPlusMinus(const char * Str)
|
||||
Purpose: Check to see if this cmd line item is of the type
|
||||
-<char>+|-. Aborts out of there was a problem.
|
||||
Params: Str = Text of item
|
||||
Returns: true if a plus option
|
||||
---------------------------------------------------------------------- */
|
||||
GString CheckFileString(const char * Str)
|
||||
{
|
||||
GString RetStr;
|
||||
|
||||
if (strlen(Str)>3 && (Str[0]=='-' || Str[0]=='/') && (Str[2]==':' || Str[2]==':'))
|
||||
RetStr=&Str[3];
|
||||
else
|
||||
GObject::Error(ERR_FATAL,"Problem with cmd line option %s",Str);
|
||||
|
||||
return(RetStr);
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function: void Usage(void)
|
||||
Notes: Usage of the util
|
||||
---------------------------------------------------------------------- */
|
||||
void Usage(void)
|
||||
{
|
||||
cout<<"Usage: PARKGRAB <file> [ <file>.. ] [ switches.. ]\n";
|
||||
cout<<"Switches:\n"<<endl;
|
||||
cout<<"-s<+|->\t\t\tSet recurse sub dirs (default off)"<<endl;
|
||||
cout<<"-c<+|->\t\t\tSet cross hair offset detection (default off)"<<endl;
|
||||
cout<<"-z<+|->\t\t\tSet colour zero trans (default off)"<<endl;
|
||||
cout<<"-m<+|->\t\t\tSet move in u/v coords (default off)"<<endl;
|
||||
cout<<"-r<+|->\t\t\tSet if spr rotation allowed (default on)"<<endl;
|
||||
cout<<"-q<+|->\t\t\tShrink to bounds of lbm (default on)"<<endl;
|
||||
cout<<"-y<+|->\t\t\tCompress tpages (default off)"<<endl;
|
||||
cout<<"-^<+|->\t\t\tDo not write a tpage (default off)"<<endl;
|
||||
cout<<"-h<+|->\t\t\tForce tpage height to half (default off)"<<endl;
|
||||
cout<<"-w<+|->\t\t\tOnly write animated headers (default off)"<<endl;
|
||||
cout<<"-b<+|->\t\t\tDo not write spare boxes (default off)"<<endl;
|
||||
cout<<"-a<+|->\t\t\tAlign headers to 2k chunk (default off)"<<endl;
|
||||
cout<<endl;
|
||||
cout<<"-f:x,y\t\t\tForce offsets for sprs to x,y"<<endl;
|
||||
cout<<"-t:b,w,h\t\tt=base tp,x=# tps wide,h=# tps high"<<endl;
|
||||
cout<<"-e:<maxsize>\t\tSet maximum size for textures"<<endl;
|
||||
cout<<"-p:<rep file>\t\tRead in a shared texture file for gin files"<<endl;
|
||||
cout<<endl;
|
||||
cout<<"-o:<filename>\t\tOutput Vram filename"<<endl;
|
||||
cout<<"-x:<filename>\t\tOutput Sprfile filename"<<endl;
|
||||
cout<<"-l:<tplbmname>\t\tWrite out an lbm of the tpage "<<endl;
|
||||
cout<<"-k:<repname>\t\tWrite out a vram report"<<endl;
|
||||
cout<<"-~:<filename>\t\tWrite out raw VRAM image"<<endl;
|
||||
cout<<endl;
|
||||
cout<<"-twisting_my_melon_man"<<endl;
|
||||
cout<<endl;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function: void AllFiles::AddFile(const char * Name)
|
||||
Purpose: Add a file to the list, it takes all the current
|
||||
properties that the AllFiles object has.
|
||||
Params: Name of file to add
|
||||
---------------------------------------------------------------------- */
|
||||
void AllFiles::AddFile(const char * Name)
|
||||
{
|
||||
DoCycle(Name,RecurseFiles);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function: void AllFiles::FileCallback(char const * FName,int FileNum)
|
||||
---------------------------------------------------------------------- */
|
||||
#include <gintex.h>
|
||||
#include <algorithm>
|
||||
|
||||
void AllFiles::FileCallback(char const * FName,int FileNum)
|
||||
{
|
||||
FileInfo MyInfo;
|
||||
bool ThisZeroColZero;
|
||||
|
||||
|
||||
GFName FileName(FName);
|
||||
|
||||
GString Ext(FileName.Ext());
|
||||
|
||||
Ext.Lower();
|
||||
|
||||
if (Ext=="gin")
|
||||
{
|
||||
vector<GString> NonSharedTextures;
|
||||
|
||||
// Gin4File MyFile;
|
||||
CScene MyFile;
|
||||
MyFile.Load(FName);
|
||||
|
||||
MyFile.GetNonSharedTextures(AllExternalSharedTextures,NonSharedTextures);
|
||||
|
||||
|
||||
vector<GString> NewEntrys;
|
||||
|
||||
for (int f=0;f<NonSharedTextures.size();f++)
|
||||
{
|
||||
if (find(UniqueTexturesSoFar.begin(),UniqueTexturesSoFar.end(),NonSharedTextures[f]) == UniqueTexturesSoFar.end())
|
||||
{
|
||||
NewEntrys.push_back(NonSharedTextures[f]);
|
||||
UniqueTexturesSoFar.push_back(NonSharedTextures[f]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (f=0;f<NewEntrys.size();f++)
|
||||
FileCallback(NewEntrys[f],0);
|
||||
|
||||
cout<<"Read gin file *"<<FName<<"*"<<endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
GFName Name(FName);
|
||||
|
||||
if (Name.File()[0]=='+')
|
||||
ThisZeroColZero=true;
|
||||
else
|
||||
ThisZeroColZero=ZeroColZero;
|
||||
|
||||
|
||||
if (Name.File()[0]=='!')
|
||||
m_allocateAs16bit=true;
|
||||
else
|
||||
m_allocateAs16bit=false;
|
||||
|
||||
if (Name.File()[0] == '@')
|
||||
{
|
||||
ThisZeroColZero = true;
|
||||
m_allocateAs16bit = true;
|
||||
}
|
||||
|
||||
GString TheFile(FName);
|
||||
TheFile.Lower();
|
||||
|
||||
MyInfo.SetInfo(TheFile,CrossHair,ThisZeroColZero,MoveUVs,AllowRotate,ShrinkToFit,m_allocateAs16bit);
|
||||
cout<<"Add image file "<<TheFile<<endl;
|
||||
|
||||
if (ForceOffsets)
|
||||
MyInfo.SetForceOffsets(XOff,YOff);
|
||||
|
||||
AllFileInfos.resize(AllFileInfos.size()+1);
|
||||
AllFileInfos[AllFileInfos.size()-1]=MyInfo;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function: void AllFiles::FileCallback(char const * FName,int FileNum)
|
||||
---------------------------------------------------------------------- */
|
||||
void AllFiles::SortOrder()
|
||||
{
|
||||
if (!m_noSort)
|
||||
{
|
||||
int i,j;
|
||||
FileInfo MyInfo;
|
||||
int count = AllFileInfos.size();
|
||||
|
||||
for (i=0; i<count; i++)
|
||||
{
|
||||
for (j=0; j<count; j++)
|
||||
{
|
||||
if (strcmp(AllFileInfos[i].GetFileName(), AllFileInfos[j].GetFileName())<0)
|
||||
{
|
||||
MyInfo = AllFileInfos[i];
|
||||
AllFileInfos[i] = AllFileInfos[j];
|
||||
AllFileInfos[j] = MyInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*===========================================================================
|
||||
end */
|
359
Utils/parkgrab/pak.cpp
Normal file
359
Utils/parkgrab/pak.cpp
Normal file
|
@ -0,0 +1,359 @@
|
|||
/*=========================================================================
|
||||
|
||||
PAK.CPP
|
||||
|
||||
Author: Gary Liddon @ Climax (from work by Nick Pelling && Carl Muller)
|
||||
Created:
|
||||
Project: Diablo PSX
|
||||
Purpose: PAK decompress \ compress code
|
||||
|
||||
Copyright (c) 1997 Climax Development Ltd
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Includes
|
||||
-------- */
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
|
||||
/* Glib
|
||||
---- */
|
||||
|
||||
/* Local
|
||||
----- */
|
||||
#include <string.h>
|
||||
#include "pak.h"
|
||||
|
||||
/* Graphics
|
||||
-------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Tyepdefs && Defines
|
||||
------------------- */
|
||||
#define UNPAKBUFFERSIZE 4096
|
||||
#define STRMAX 80
|
||||
#define BUFFERSIZE 30000
|
||||
#define TRIGGER 20000
|
||||
#define MAXUNIQUE 127
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Structure defintions
|
||||
-------------------- */
|
||||
struct Block
|
||||
{
|
||||
int data[128];
|
||||
BOOL blockrep;
|
||||
int blocksize;
|
||||
int blockoffset;
|
||||
|
||||
u8 * Dest;
|
||||
int outsize;
|
||||
|
||||
virtual void fputc(u8 Val)
|
||||
{
|
||||
*Dest=Val;
|
||||
Dest++;
|
||||
outsize++;
|
||||
}
|
||||
|
||||
void writeBlock(void);
|
||||
};
|
||||
|
||||
struct CountBlock : Block
|
||||
{
|
||||
virtual void fputc(u8 Val)
|
||||
{
|
||||
Dest++;
|
||||
outsize++;
|
||||
}
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Vars
|
||||
---- */
|
||||
static int s_lastAmountOfCompressedData;
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function Prototypes
|
||||
------------------- */
|
||||
static void writeblock(struct block *theblock);
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Vars
|
||||
---- */
|
||||
/*----------------------------------------------------------------------
|
||||
Data
|
||||
---- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void Block::writeBlock(void)
|
||||
{
|
||||
if ((blockrep) && (blocksize == 0))
|
||||
{
|
||||
/* Terminator */
|
||||
fputc(128);
|
||||
fputc(0);
|
||||
}
|
||||
else if (blockrep)
|
||||
{
|
||||
fputc(blockoffset);
|
||||
fputc(blocksize);
|
||||
}
|
||||
else /* Unique bytes */
|
||||
{
|
||||
fputc(blocksize & 127);
|
||||
|
||||
for (int i = 0; i <= blocksize; i++)
|
||||
fputc(data[i]);
|
||||
}
|
||||
|
||||
// Get ready for next block
|
||||
blockrep = FALSE;
|
||||
blockoffset = 0;
|
||||
blocksize = -1;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
static bool memequ(u8 const * p1,u8 const * p2,int size)
|
||||
{
|
||||
bool same;
|
||||
|
||||
same=true;
|
||||
|
||||
for (int f=0;f<size && same;f++)
|
||||
same=p1[f]==p2[f];
|
||||
|
||||
return(same);
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
int lowLevelPak(u8 * Dest,u8 const * buffer,int insize,Block & theblock)
|
||||
{
|
||||
long begin, end, bestlength;
|
||||
int offset, bestoffset;
|
||||
unsigned char const * theptr;
|
||||
unsigned char const * ptr1;
|
||||
unsigned char const * ptr2;
|
||||
unsigned char const * ptr3;
|
||||
long BACKDIST, FORWARDDIST, MINBLOCK;
|
||||
|
||||
theblock.Dest=Dest;
|
||||
theblock.outsize=0;
|
||||
theblock.blockrep=FALSE;
|
||||
|
||||
BACKDIST = -128;
|
||||
FORWARDDIST = 255;
|
||||
MINBLOCK = 3;
|
||||
|
||||
int inpos = 0;
|
||||
|
||||
theblock.blocksize = -1;
|
||||
theblock.data[++theblock.blocksize] = buffer[inpos++];
|
||||
theblock.data[++theblock.blocksize] = buffer[inpos++];
|
||||
|
||||
while (inpos < insize)
|
||||
{
|
||||
/* See if we should load new data into the buffer */
|
||||
|
||||
begin = -inpos;
|
||||
end = insize - inpos;
|
||||
|
||||
if (begin < BACKDIST)
|
||||
begin = BACKDIST;
|
||||
|
||||
if (end > FORWARDDIST)
|
||||
end = FORWARDDIST;
|
||||
|
||||
bestoffset = begin;
|
||||
bestlength = 1;
|
||||
theptr = buffer + (inpos);
|
||||
|
||||
ptr1 = buffer + (inpos + begin);
|
||||
|
||||
for (offset = begin; offset < 0; offset++)
|
||||
{
|
||||
if (*ptr1 == *theptr)
|
||||
{
|
||||
if (memequ(ptr1, theptr, bestlength + 1))
|
||||
{
|
||||
bestlength++;
|
||||
bestoffset = offset;
|
||||
ptr2 = ptr1 + bestlength;
|
||||
ptr3 = theptr + bestlength;
|
||||
|
||||
while (*ptr2 == *ptr3)
|
||||
{
|
||||
ptr2++;
|
||||
ptr3++;
|
||||
bestlength++;
|
||||
if (bestlength >= end)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bestlength >= end)
|
||||
{
|
||||
bestlength = end;
|
||||
break;
|
||||
}
|
||||
|
||||
ptr1++;
|
||||
}
|
||||
|
||||
|
||||
if (bestlength < MINBLOCK)
|
||||
{
|
||||
/* See if last block is unique */
|
||||
|
||||
if (theblock.blockrep) /* Flush previous special block */
|
||||
{
|
||||
theblock.writeBlock();
|
||||
theblock.data[++theblock.blocksize] = buffer[inpos++];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Add to it */
|
||||
|
||||
if (theblock.blocksize >= MAXUNIQUE)
|
||||
theblock.writeBlock();
|
||||
|
||||
theblock.data[++theblock.blocksize] = buffer[inpos++];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We have found a match */
|
||||
theblock.writeBlock();
|
||||
theblock.blockrep = TRUE;
|
||||
theblock.blocksize = bestlength;
|
||||
theblock.blockoffset = bestoffset;
|
||||
inpos += bestlength;
|
||||
}
|
||||
}
|
||||
|
||||
/* Flush buffer */
|
||||
|
||||
theblock.writeBlock();
|
||||
|
||||
/* Terminate file */
|
||||
|
||||
theblock.blockrep = TRUE;
|
||||
theblock.blocksize = 0;
|
||||
theblock.blockoffset = 0;
|
||||
theblock.writeBlock();
|
||||
|
||||
return(theblock.outsize);
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
int PAK_doPak(u8 * Dest,u8 const * buffer,int insize)
|
||||
{
|
||||
Block outBlock;
|
||||
return(lowLevelPak(Dest,buffer,insize,outBlock));
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
int PAK_findPakSize(u8 const * buffer,int insize)
|
||||
{
|
||||
CountBlock outBlock;
|
||||
return(lowLevelPak(NULL,buffer,insize,outBlock));
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
int PAK_doUnpak(u8 * Dest,u8 const * Source)
|
||||
{
|
||||
int outsize = 0;
|
||||
u8 const * originalSource;
|
||||
|
||||
originalSource=Source;
|
||||
|
||||
while (1) /* ie, continue until end mark */
|
||||
{
|
||||
u8 const * From;
|
||||
|
||||
int size;
|
||||
int ch;
|
||||
|
||||
ch = *Source++;
|
||||
|
||||
if (ch < 128) /* if it is in range {0..127} then */
|
||||
{
|
||||
size = (ch + 1);
|
||||
From=Source;
|
||||
Source+=size;
|
||||
}
|
||||
else
|
||||
{
|
||||
size = *Source++;
|
||||
|
||||
if (size == 0) /* distance == 0 => end of file */
|
||||
break;
|
||||
|
||||
From=Dest+(s8)ch;
|
||||
}
|
||||
|
||||
u8 * endAddr;
|
||||
endAddr=(u8*)(u32(From)+size);
|
||||
|
||||
outsize += size;
|
||||
|
||||
while (From!=endAddr)
|
||||
{
|
||||
*Dest=*From;
|
||||
Dest++;
|
||||
From++;
|
||||
}
|
||||
}
|
||||
|
||||
s_lastAmountOfCompressedData=Source-originalSource;
|
||||
|
||||
return(outsize);
|
||||
}
|
||||
|
||||
int PAK_getLastAmountOfDataRead(void)
|
||||
{
|
||||
return(s_lastAmountOfCompressedData);
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
||||
|
||||
|
||||
|
||||
|
61
Utils/parkgrab/pak.h
Normal file
61
Utils/parkgrab/pak.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*=========================================================================
|
||||
|
||||
PAK.H
|
||||
|
||||
Author: Carl Muller (algorithm Nick Pelling && Carl Muller)
|
||||
Created:
|
||||
Project:
|
||||
Purpose:
|
||||
|
||||
Copyright (c) 1997 Climax Development Ltd
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
#ifndef __PAK_PAK_H__
|
||||
#define __PAK_PAK_H__
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Includes
|
||||
-------- */
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
|
||||
/* Glib
|
||||
---- */
|
||||
#include <gtypes.h>
|
||||
|
||||
/* Local
|
||||
----- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Tyepdefs && Defines
|
||||
------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Structure defintions
|
||||
-------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Globals
|
||||
------- */
|
||||
|
||||
/* Vars
|
||||
---- */
|
||||
|
||||
/* Data
|
||||
---- */
|
||||
|
||||
/* Functions
|
||||
--------- */
|
||||
int PAK_doPak(u8 * Dest,u8 const * source,int insize);
|
||||
int PAK_doUnpak(u8 * Dest,u8 const * Source);
|
||||
int PAK_findPakSize(u8 const * souce,int insize);
|
||||
int PAK_getLastAmountOfDataRead(void);
|
||||
|
||||
/*---------------------------------------------------------------------- */
|
||||
|
||||
#endif /* __PAK_PAK_H__ */
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
154
Utils/parkgrab/parkgrab.dsp
Normal file
154
Utils/parkgrab/parkgrab.dsp
Normal file
|
@ -0,0 +1,154 @@
|
|||
# Microsoft Developer Studio Project File - Name="parkgrab" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=parkgrab - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "parkgrab.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "parkgrab.mak" CFG="parkgrab - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "parkgrab - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "parkgrab - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""$/tp2psx/utils/parkgrab", IXNAAAAA"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "parkgrab - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\glibdev\glib\include" /I "..\glibdev\glib\include\pc" /I "..\ginutils\tplib" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
|
||||
# ADD BASE RSC /l 0x809 /d "NDEBUG"
|
||||
# ADD RSC /l 0x809 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib win32lib.lib tplib.lib /nologo /subsystem:console /machine:I386 /out:"../../tools/parkgrab.exe" /libpath:"..\glibdev\glib\lib\win32lib\release" /libpath:"..\ginutils\tplib\release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "parkgrab - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /G5 /MDd /W3 /Gm /GX /ZI /Od /I "..\glibdev\glib\include" /I "..\glibdev\glib\include\pc" /I "..\ginutils\tplib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
# ADD RSC /l 0x809 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib win32lib.lib tplib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\glibdev\glib\lib\win32lib\debug" /libpath:"..\ginutils\tplib\debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "parkgrab - Win32 Release"
|
||||
# Name "parkgrab - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\bmploader.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cross.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\grect.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\main.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\pak.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\sprset.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tpage.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\VImage.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\bmploader.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cross.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\grect.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\pak.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\sprset.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tpage.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\vimage.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
33
Utils/parkgrab/parkgrab.dsw
Normal file
33
Utils/parkgrab/parkgrab.dsw
Normal file
|
@ -0,0 +1,33 @@
|
|||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "parkgrab"=.\parkgrab.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
begin source code control
|
||||
"$/PRLSR/utils/parkgrab", TCEAAAAA
|
||||
.
|
||||
end source code control
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
BIN
Utils/parkgrab/parkgrab.ncb
Normal file
BIN
Utils/parkgrab/parkgrab.ncb
Normal file
Binary file not shown.
1314
Utils/parkgrab/sprset.cpp
Normal file
1314
Utils/parkgrab/sprset.cpp
Normal file
File diff suppressed because it is too large
Load diff
569
Utils/parkgrab/sprset.h
Normal file
569
Utils/parkgrab/sprset.h
Normal file
|
@ -0,0 +1,569 @@
|
|||
/*=========================================================================
|
||||
|
||||
SPRSET.CPP
|
||||
|
||||
Author: Gary Liddon @ Farehame
|
||||
Created:
|
||||
Project: TPW Parkgrab
|
||||
Purpose: Object that reads in all the frames for sprites
|
||||
processes them into tpages and spits it all out to
|
||||
disk
|
||||
|
||||
Copyright (c) 1998 G R Liddon
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
#ifndef __SPRSET_H__
|
||||
#define __SPRSET_H__
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Includes
|
||||
-------- */
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
#include <vector>
|
||||
|
||||
/* Glib
|
||||
---- */
|
||||
#include <gobject.hpp>
|
||||
#include <gstring.hpp>
|
||||
#include <frame.hpp>
|
||||
#include <misc.hpp>
|
||||
|
||||
/* Local
|
||||
----- */
|
||||
#include "tpage.h"
|
||||
#include "vimage.h"
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Tyepdefs && Defines
|
||||
------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Structure defintions
|
||||
-------------------- */
|
||||
|
||||
/* Encapsulates a file and all the infomation parkgrab needs to process it
|
||||
----------------------------------------------------------------------- */
|
||||
class FileInfo
|
||||
{
|
||||
public:
|
||||
FileInfo(void)
|
||||
{
|
||||
CrossHair=false;
|
||||
ForceOffsets=false;
|
||||
}
|
||||
|
||||
FileInfo(FileInfo const & Fi)
|
||||
{
|
||||
operator=(Fi);
|
||||
}
|
||||
|
||||
void operator=(FileInfo const & Fi)
|
||||
{
|
||||
FileName = Fi.FileName;
|
||||
strcpy(ActualFileName,Fi.ActualFileName);
|
||||
CrossHair=Fi.CrossHair;
|
||||
ZeroColZero = Fi.ZeroColZero;
|
||||
PlusColZero = Fi.PlusColZero;
|
||||
MoveUVs = Fi.MoveUVs;
|
||||
AllowRotate=Fi.AllowRotate;
|
||||
ForceOffsets=Fi.ForceOffsets;
|
||||
XOff=Fi.XOff;
|
||||
YOff=Fi.YOff;
|
||||
ShrinkToFit=Fi.ShrinkToFit;
|
||||
m_allocateAs16Bit=Fi.m_allocateAs16Bit;
|
||||
}
|
||||
|
||||
void SetForceOffsets(int x,int y)
|
||||
{
|
||||
ForceOffsets=true;
|
||||
XOff=x;
|
||||
YOff=y;
|
||||
}
|
||||
|
||||
GString CheckForPlus(GString s)
|
||||
{
|
||||
GString out;
|
||||
const char *textin = (const char*)s;
|
||||
char *textout = new char[s.Len()+1];
|
||||
memset(textout, 0, s.Len()+1);
|
||||
int p;
|
||||
bool plus;
|
||||
|
||||
p=0;
|
||||
if (textin[0] == '+') plus = true;
|
||||
else plus = false;
|
||||
/* for (i=0; i<s.Len(); i++)
|
||||
{
|
||||
textout[i]=textin[i];
|
||||
if (textout[i] == '+') plus = true;
|
||||
// p++;
|
||||
// else p++;
|
||||
}
|
||||
*/ PlusColZero = plus;
|
||||
|
||||
out = textin;
|
||||
delete textout;
|
||||
return out;
|
||||
}
|
||||
|
||||
void SetInfo(const char * NewFileName,bool NewCrossHair,bool NewZeroColZero, bool NewMoveUVs,bool NewAllowRotate,bool NewShrinkToFit,bool allocateAs16Bit)
|
||||
{
|
||||
CrossHair=NewCrossHair;
|
||||
ZeroColZero=NewZeroColZero;
|
||||
MoveUVs =NewMoveUVs;
|
||||
AllowRotate=NewAllowRotate;
|
||||
SetName(NewFileName);
|
||||
ShrinkToFit=NewShrinkToFit;
|
||||
|
||||
m_allocateAs16Bit=allocateAs16Bit;
|
||||
|
||||
/*
|
||||
if we're allocating on a 16 bit pixel boundary then
|
||||
we don't want the texture to be rotated
|
||||
*/
|
||||
|
||||
if (allocateAs16Bit)
|
||||
AllowRotate=false;
|
||||
}
|
||||
|
||||
const char * GetFileName(void) const
|
||||
{return(FileName);}
|
||||
|
||||
const char * GetActualFileName(void) const
|
||||
{return(ActualFileName);}
|
||||
|
||||
void SetName(const char * NewName)
|
||||
{
|
||||
if (NewName) strcpy(ActualFileName,NewName);
|
||||
FileName = CheckForPlus(ActualFileName);
|
||||
}
|
||||
|
||||
bool GetCrossHair(void) const
|
||||
{return(CrossHair);}
|
||||
|
||||
bool GetZeroColZero(void) const
|
||||
{return(ZeroColZero);}
|
||||
|
||||
bool GetPlusColZero(void) const
|
||||
{return(PlusColZero);}
|
||||
|
||||
bool GetMoveUVs(void) const
|
||||
{return(MoveUVs);}
|
||||
|
||||
bool GetAllowRotate(void) const
|
||||
{return(AllowRotate);}
|
||||
|
||||
bool GetForceOffsets(void) const
|
||||
{
|
||||
return(ForceOffsets);
|
||||
}
|
||||
|
||||
int GetXOff(void) const
|
||||
{
|
||||
return(XOff);
|
||||
}
|
||||
|
||||
int GetYOff(void) const
|
||||
{
|
||||
return(YOff);
|
||||
}
|
||||
|
||||
bool getAllocateAs16Bit(void) const
|
||||
{return(m_allocateAs16Bit);}
|
||||
|
||||
char const * GetActualName(void) const
|
||||
{return(ActualFileName);}
|
||||
|
||||
bool GetShrinkToFit(void) const
|
||||
{return(ShrinkToFit);}
|
||||
|
||||
protected:
|
||||
GString FileName;
|
||||
char ActualFileName[256];
|
||||
bool CrossHair;
|
||||
bool ZeroColZero;
|
||||
bool PlusColZero;
|
||||
bool MoveUVs;
|
||||
bool AllowRotate;
|
||||
bool ForceOffsets;
|
||||
bool ShrinkToFit;
|
||||
|
||||
bool m_allocateAs16Bit;
|
||||
|
||||
int XOff,YOff;
|
||||
};
|
||||
|
||||
typedef std::vector<FileInfo> FIVec;
|
||||
typedef std::vector<FileInfo>::iterator FIVecIt;
|
||||
typedef std::vector<FileInfo>::const_iterator FIVecConstIt;
|
||||
|
||||
|
||||
/* A Palette of graphics with sprset specific stuff
|
||||
---------------------------------------------- */
|
||||
class SprPal : public Palette
|
||||
{
|
||||
public:
|
||||
SprPal(void)
|
||||
{}
|
||||
|
||||
SprPal(SprPal const & Pal)
|
||||
{MakeCopy(Pal);}
|
||||
|
||||
void operator=(SprPal const & Pal)
|
||||
{MakeCopy(Pal);}
|
||||
|
||||
void operator=(Palette const & Pal)
|
||||
{Palette::CopyPal(Pal);}
|
||||
|
||||
bool operator==(Palette const & Pal)
|
||||
{return(Palette::operator==(Pal));}
|
||||
|
||||
bool operator<(SprPal const & Pal)
|
||||
{return(GetNumOfCols() < Pal.GetNumOfCols());}
|
||||
|
||||
void SetPalIndex(int NewPalIndex)
|
||||
{PalIndex=NewPalIndex;}
|
||||
|
||||
int GetPalIndex(void) const
|
||||
{return(PalIndex);}
|
||||
|
||||
void SetVRAMPos(TPRect & NewRect)
|
||||
{
|
||||
MyRect=NewRect;
|
||||
}
|
||||
|
||||
void SetTpBase(int NewTpBase)
|
||||
{
|
||||
TpBase=NewTpBase;
|
||||
BaseTpX=((TpBase&0xf)*64);
|
||||
BaseTpY=(TpBase>>4)*256;
|
||||
}
|
||||
|
||||
u16 GetClut(void)
|
||||
{
|
||||
int x=(MyRect.X/4)+BaseTpX;
|
||||
int y=MyRect.Y+BaseTpY;
|
||||
return((y<<6)|((x>>4)&0x3f));
|
||||
}
|
||||
|
||||
TPRect const & GetTPRect(void) const
|
||||
{return(MyRect);}
|
||||
|
||||
char const * GetName(void) const
|
||||
{return(Name);}
|
||||
|
||||
void SetName(char const * NewName)
|
||||
{Name=NewName;}
|
||||
|
||||
void SetZeroColZero(bool New)
|
||||
{ZeroColZero=New;}
|
||||
|
||||
bool GetZeroColZero(void) const
|
||||
{return(ZeroColZero);}
|
||||
|
||||
void SetPlusColZero(bool New)
|
||||
{PlusColZero=New;}
|
||||
|
||||
bool GetPlusColZero(void) const
|
||||
{return(PlusColZero);}
|
||||
|
||||
void Write(Gofstream & Out) const;
|
||||
void MakePSXPal(std::vector<u16> & OutWord) const;
|
||||
u16 GetPsxCol(Colour const & Col) const;
|
||||
|
||||
protected:
|
||||
int PalIndex;
|
||||
int TpBase;
|
||||
int BaseTpX;
|
||||
int BaseTpY;
|
||||
bool ZeroColZero;
|
||||
bool PlusColZero;
|
||||
TPRect MyRect;
|
||||
GString Name;
|
||||
|
||||
void MakeCopy(SprPal const & NewPal)
|
||||
{
|
||||
Palette::CopyPal(NewPal);
|
||||
PalIndex=NewPal.PalIndex;
|
||||
TpBase=NewPal.TpBase;
|
||||
BaseTpX=NewPal.BaseTpX;
|
||||
BaseTpY=NewPal.BaseTpY;
|
||||
MyRect=NewPal.MyRect;
|
||||
Name=NewPal.Name;
|
||||
ZeroColZero=NewPal.ZeroColZero;
|
||||
PlusColZero=NewPal.PlusColZero;
|
||||
}
|
||||
};
|
||||
|
||||
/* A Frame of graphics with sprset specific stuff
|
||||
---------------------------------------------- */
|
||||
class SprFrame : public Frame
|
||||
{
|
||||
public:
|
||||
enum BDEPTH
|
||||
{
|
||||
BITS_4,
|
||||
BITS_8,
|
||||
};
|
||||
|
||||
SprFrame(void);
|
||||
SprFrame(SprFrame const & NewFrame)
|
||||
{MakeCopy(NewFrame);}
|
||||
|
||||
void operator=(SprFrame const & NewFrame)
|
||||
{MakeCopy(NewFrame);}
|
||||
|
||||
void SetFrameAndInfo(Frame const & Fr,FileInfo const & MyFileInfo,int MaxSize);
|
||||
FileInfo * GetFileInfo(void)
|
||||
{
|
||||
return (&MyFileInfo);
|
||||
}
|
||||
|
||||
void Process(void);
|
||||
|
||||
void SetPalIndex(int NewPalIndex)
|
||||
{PalIndex=NewPalIndex;}
|
||||
|
||||
int GetPalIndex(void) const
|
||||
{return(PalIndex);}
|
||||
|
||||
void SetVRAMPos(TPRect const & Rect);
|
||||
|
||||
BDEPTH GetBitDepth(void) const
|
||||
{
|
||||
BDEPTH RetDepth;
|
||||
int NumOfCols;
|
||||
|
||||
NumOfCols=MyPal.GetNumOfCols();
|
||||
|
||||
if (NumOfCols<=16)
|
||||
RetDepth=BITS_4;
|
||||
else
|
||||
RetDepth=BITS_8;
|
||||
|
||||
return(RetDepth);
|
||||
}
|
||||
|
||||
TPRect const & GetTPRect(void) const
|
||||
{return(MyRect);}
|
||||
|
||||
bool IsRotated(void) const
|
||||
{return(MyRect.GetRotate());}
|
||||
|
||||
void SetTpBase(int NewTpBase)
|
||||
{
|
||||
TpBase=NewTpBase;
|
||||
BaseTpX=((TpBase&0xf)*64);
|
||||
BaseTpY=(TpBase>>4)*256;
|
||||
}
|
||||
|
||||
void SetClut(u16 NewClut)
|
||||
{Clut=NewClut;}
|
||||
|
||||
u16 GetClut(void) const
|
||||
{return(Clut);}
|
||||
|
||||
void WriteHeader(Gofstream & Out);
|
||||
|
||||
bool GetZeroColZero(void) const
|
||||
{return(MyFileInfo.GetZeroColZero());}
|
||||
|
||||
bool GetPlusColZero(void) const
|
||||
{return(MyFileInfo.GetPlusColZero());}
|
||||
|
||||
bool GetAllowRotate(void) const
|
||||
{return(MyFileInfo.GetAllowRotate());}
|
||||
|
||||
|
||||
void Write(Gofstream & Out) const;
|
||||
|
||||
void WriteHeaderNotInVram(Gofstream & Out);
|
||||
|
||||
|
||||
int getV(void)
|
||||
{return(MyRect.X&0xff);}
|
||||
|
||||
int getU(void)
|
||||
{
|
||||
u16 tpage;
|
||||
int u;
|
||||
int pageX;
|
||||
|
||||
tpage=GetTpage();
|
||||
pageX=(tpage&0xf)*256;
|
||||
u=MyRect.X-pageX;
|
||||
|
||||
switch(GetBitDepth())
|
||||
{
|
||||
case BITS_8:
|
||||
u/=2;
|
||||
break;
|
||||
}
|
||||
|
||||
return(u);
|
||||
}
|
||||
|
||||
u16 GetTpage(void)
|
||||
{
|
||||
int tp;
|
||||
BDEPTH RetDepth;
|
||||
|
||||
RetDepth=GetBitDepth();
|
||||
|
||||
int abr=0;
|
||||
int x=BaseTpX + (MyRect.X/4); //MA
|
||||
int y=BaseTpY + MyRect.Y; //MA
|
||||
|
||||
switch(RetDepth)
|
||||
{
|
||||
case BITS_4:
|
||||
tp=0;
|
||||
break;
|
||||
case BITS_8:
|
||||
tp=1;
|
||||
break;
|
||||
}
|
||||
|
||||
return((((tp)&0x3)<<7)|(((abr)&0x3)<<5)|(((y)&0x100)>>4)|(((x)&0x3ff)>>6)| (((y)&0x200)<<2));
|
||||
}
|
||||
|
||||
bool IsAnimated()
|
||||
{
|
||||
return(MyFileInfo.getAllocateAs16Bit());
|
||||
}
|
||||
protected:
|
||||
void ResizeAndReduce(Frame & Frm,int TargCols,float XPerc,float YPerc,bool ZeroSeeThrough);
|
||||
|
||||
|
||||
void MakeCopy(SprFrame const & NewFrame)
|
||||
{
|
||||
Frame::CopyFrame(NewFrame);
|
||||
|
||||
Clut=NewFrame.Clut;
|
||||
TpBase=NewFrame.TpBase;
|
||||
BaseTpX=NewFrame.BaseTpX;
|
||||
BaseTpY=NewFrame.BaseTpY;
|
||||
PalIndex=NewFrame.PalIndex;
|
||||
MyFileInfo=NewFrame.MyFileInfo;
|
||||
MyRect=NewFrame.MyRect;
|
||||
}
|
||||
|
||||
|
||||
u16 Clut;
|
||||
int TpBase;
|
||||
int BaseTpX;
|
||||
int BaseTpY;
|
||||
|
||||
GString loadFileName;
|
||||
|
||||
int PalIndex;
|
||||
FileInfo MyFileInfo;
|
||||
TPRect MyRect;
|
||||
};
|
||||
|
||||
/* A collection of sprites
|
||||
----------------------- */
|
||||
class SprSet : protected GObject
|
||||
{
|
||||
public:
|
||||
SprSet(void)
|
||||
{
|
||||
Vi=NULL;
|
||||
MaxSize=0;
|
||||
}
|
||||
|
||||
void SetMaxSize(int New)
|
||||
{MaxSize=New;}
|
||||
|
||||
void AddFiles(FIVec const & FileList);
|
||||
|
||||
void Write(char const * FileName,int TpNumber,int WidthInTpages,int HeightInTpages);
|
||||
void WriteLBM(char const * FileName);
|
||||
void WriteSprFile(char const * Name);
|
||||
void WriteReport(char const * Name);
|
||||
void writeRawTPage(char const * File);
|
||||
void SetIncOutFile(char const * NewIncOutFile)
|
||||
{IncOutFile=NewIncOutFile;IncOutFile.Lower();}
|
||||
|
||||
void setAnimatedHeader(bool newVal)
|
||||
{m_AnimatedHeadersOnly=newVal;}
|
||||
|
||||
void setDontOutputBoxes(bool newVal)
|
||||
{m_DontOutputBoxes=newVal;}
|
||||
|
||||
void setAlignHeaders(bool newVal)
|
||||
{m_AlignHeaders=newVal;}
|
||||
|
||||
void setHalfTpage(bool newVal)
|
||||
{m_halfTpage=newVal;}
|
||||
|
||||
void setCompressTpages(bool newVal)
|
||||
{m_compressTpages=newVal;}
|
||||
|
||||
void setNoWriteTpages(bool newVal)
|
||||
{m_noWriteTpages=newVal;}
|
||||
|
||||
protected:
|
||||
void WriteHeaderFile(char const * HName);
|
||||
|
||||
void ProcessPals(void);
|
||||
void AddFile(FileInfo const & ThisInfo);
|
||||
void AddAnm(FileInfo const & ThisInfo);
|
||||
void AddLbm(FileInfo const & ThisInfo);
|
||||
void AddFrame(Frame const & Fr,FileInfo const & ThisInfo);
|
||||
|
||||
void AddFramesAndPalsToVRAM(VRAM & Vr,int TpNumber,int WidthInTpages,int HeightInPixels);
|
||||
|
||||
GString GetHeaderFileName(char const * File);
|
||||
|
||||
|
||||
typedef std::vector<SprFrame> SprFrVec;
|
||||
typedef std::vector<SprFrame>::iterator SprFrIt;
|
||||
|
||||
typedef std::vector<SprPal> SprPalVec;
|
||||
typedef std::vector<SprPal>::iterator SprPalVecIt;
|
||||
|
||||
GString IncOutFile;
|
||||
|
||||
bool m_AnimatedHeadersOnly;
|
||||
bool m_DontOutputBoxes;
|
||||
bool m_AlignHeaders;
|
||||
bool m_halfTpage;
|
||||
bool m_compressTpages;
|
||||
bool m_noWriteTpages;
|
||||
|
||||
SprFrVec AllSprFrames;
|
||||
SprPalVec AllSprPals;
|
||||
VRAMImage * Vi;
|
||||
|
||||
int MaxSize;
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Globals
|
||||
------- */
|
||||
|
||||
/* Vars
|
||||
---- */
|
||||
|
||||
/* Data
|
||||
---- */
|
||||
|
||||
/* Functions
|
||||
--------- */
|
||||
|
||||
/*---------------------------------------------------------------------- */
|
||||
|
||||
#else /* __SPRSET_H__ */
|
||||
|
||||
class SprPal;
|
||||
class SprFrame;
|
||||
|
||||
#endif
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
857
Utils/parkgrab/tpage.cpp
Normal file
857
Utils/parkgrab/tpage.cpp
Normal file
|
@ -0,0 +1,857 @@
|
|||
/*=========================================================================
|
||||
|
||||
FILENAME.CPP
|
||||
|
||||
Author: Gary Liddon @
|
||||
Created:
|
||||
Project:
|
||||
Purpose:
|
||||
|
||||
Copyright (c) 1997 Climax Development Ltd
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Includes
|
||||
-------- */
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
#include <algorithm>
|
||||
#include "conio.h"
|
||||
|
||||
/* Glib
|
||||
---- */
|
||||
#include "gutils.h"
|
||||
|
||||
/* Local
|
||||
----- */
|
||||
#include "tpage.h"
|
||||
#include "grect.h"
|
||||
|
||||
/* Graphics
|
||||
-------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Tyepdefs && Defines
|
||||
------------------- */
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Structure defintions
|
||||
-------------------- */
|
||||
struct TPInfo
|
||||
{
|
||||
int XAlign;
|
||||
int TpWidth;
|
||||
int BorderX;
|
||||
int BorderY;
|
||||
};
|
||||
|
||||
/* Information about where I can place this frame in the Tpage
|
||||
----------------------------------------------------------- */
|
||||
/*----------------------------------------------------------------------
|
||||
Vars
|
||||
---- */
|
||||
static TPInfo const InfStruct[TP_NUM_OF_TP_TYPES]=
|
||||
{
|
||||
{1,256,1,1}, /* TP_4 */
|
||||
{2,512,2,1}, /* TP_8 */
|
||||
{4,256,4,1}, /* TP_16 */
|
||||
{0,0,0,0}, /* TP_SCREEN */
|
||||
{16*4,1024*4,0,0}, /* TP_PAL */
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function Prototypes
|
||||
------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Vars
|
||||
---- */
|
||||
int TPRect::W2Alloc=1;
|
||||
int TPRect::H2Alloc=1;
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Data
|
||||
---- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
VRAM::VRAM(int nTpWidth,int nTpHeightInPixels)
|
||||
{
|
||||
Big2Little=false;
|
||||
RotateEveryEmpty=false;
|
||||
|
||||
|
||||
TpWidth=-1;
|
||||
TpHeightInPixels=-1;
|
||||
|
||||
Clear(nTpWidth,nTpHeightInPixels);
|
||||
}
|
||||
|
||||
void VRAM::Clear(int nTpWidth,int nTpHeightInPixels)
|
||||
{
|
||||
if (nTpWidth >= 0 )
|
||||
TpWidth=nTpWidth;
|
||||
|
||||
if (nTpHeightInPixels >= 0)
|
||||
TpHeightInPixels=nTpHeightInPixels;
|
||||
|
||||
InitEmpty(0,0,TpWidth*256,TpHeightInPixels);
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function: void VRAM::InitEmpty(void)
|
||||
Purpose: Initialise the VRAM as empty
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void VRAM::InitEmpty(int vX,int vY,int nW,int nH)
|
||||
{
|
||||
const int Width16=256;
|
||||
const int Height16=256;
|
||||
|
||||
W=nW;
|
||||
H=nH;
|
||||
X=vX;
|
||||
Y=vY;
|
||||
|
||||
VRAMWidthPages=W/Width16;
|
||||
VRAMHeightPages=H/Height16;
|
||||
|
||||
if (!VRAMHeightPages)
|
||||
{
|
||||
VRAMHeightPages = 1;
|
||||
}
|
||||
|
||||
NumOfTPages=VRAMWidthPages*VRAMHeightPages;
|
||||
|
||||
VecOfPages.resize(NumOfTPages,TPRectList());
|
||||
|
||||
Unused.reserve(4000);
|
||||
Used.reserve(2000);
|
||||
|
||||
Unused.resize(0);
|
||||
Used.resize(0);
|
||||
|
||||
for (int f=0;f<NumOfTPages;f++)
|
||||
VecOfPages[f].resize(0);
|
||||
|
||||
for (int y=0;y<VRAMHeightPages;y++)
|
||||
for (int x=0;x<VRAMWidthPages;x++)
|
||||
AddEmpty((x*Width16)+vX,(y*Height16)+vY,Width16,Height16);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function: bool TryNFit(TPRectList & TpList)
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
bool VRAM::TryNFit(TPRectList & TpList,TPRect & ThisRect)
|
||||
{
|
||||
bool Done=false;
|
||||
|
||||
TPRectList::iterator f;
|
||||
|
||||
|
||||
for (f=TpList.begin();f!=TpList.end();f++)
|
||||
{
|
||||
TPRect & BlankRect = *f;
|
||||
|
||||
if (TryRect(BlankRect,ThisRect))
|
||||
return(true);
|
||||
else
|
||||
{
|
||||
if (RotateEveryEmpty && CanRotate(ThisRect))
|
||||
{
|
||||
ThisRect.SetRotate(!ThisRect.GetRotate());
|
||||
|
||||
if (TryRect(BlankRect,ThisRect))
|
||||
return(true);
|
||||
else
|
||||
ThisRect.SetRotate(!ThisRect.GetRotate());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(false);
|
||||
}
|
||||
|
||||
void VRAM::PosFromTPrect(TPRect & ThisRect,POS_INFO & Pi)
|
||||
{
|
||||
TPInfo const * Tpi;
|
||||
int WorkingWidth;
|
||||
|
||||
Tpi=&InfStruct[ThisRect.TypeOfPage];
|
||||
Pi.XAlign=Tpi->XAlign;
|
||||
|
||||
WorkingWidth=GU_AlignVal(ThisRect.W,Pi.XAlign);
|
||||
|
||||
Pi.MinX=Tpi->BorderX;
|
||||
Pi.MinY=Tpi->BorderY;
|
||||
Pi.MaxX=W-Tpi->BorderX-WorkingWidth;
|
||||
Pi.MaxY=H-Tpi->BorderY-ThisRect.H;
|
||||
|
||||
Pi.TpWidthPix=Tpi->TpWidth;
|
||||
|
||||
Pi.MinXTp=Tpi->BorderX;
|
||||
Pi.MaxXTp=Tpi->TpWidth-Tpi->BorderX-WorkingWidth;
|
||||
|
||||
Pi.MinYTp=Tpi->BorderY;
|
||||
Pi.MaxYTp=(256-Tpi->BorderY)-ThisRect.H;
|
||||
}
|
||||
|
||||
bool VRAM::TryRect(TPRect & BlankRect,TPRect & ThisRect)
|
||||
{
|
||||
POS_INFO Pi;
|
||||
PosFromTPrect(ThisRect,Pi);
|
||||
|
||||
int MinTpX=Pi.MinXTp+(BlankRect.X/Pi.TpWidthPix)*Pi.TpWidthPix;
|
||||
int MaxTpX=Pi.MaxXTp+(BlankRect.X/Pi.TpWidthPix)*Pi.TpWidthPix;
|
||||
int MinTpY=Pi.MinYTp+(BlankRect.Y/256)*256;
|
||||
int MaxTpY=Pi.MaxYTp+(BlankRect.Y/256)*256;
|
||||
|
||||
/* Move to avoid edges of the map */
|
||||
int MinX = MinTpX > Pi.MinX ? MinTpX : Pi.MinX;
|
||||
int MaxX = MaxTpX < Pi.MaxX ? MaxTpX : Pi.MaxX;
|
||||
int MinY = MinTpY > Pi.MinY ? MinTpY : Pi.MinY;
|
||||
int MaxY = MaxTpY < Pi.MaxY ? MaxTpY : Pi.MaxY;
|
||||
|
||||
int ThisX=GU_AlignVal(BlankRect.X,Pi.XAlign);
|
||||
int ThisY=BlankRect.Y;
|
||||
|
||||
if (ThisX<MinX)
|
||||
ThisX=MinX;
|
||||
|
||||
if (ThisX>MaxX)
|
||||
return(false);
|
||||
|
||||
if (ThisY<MinY)
|
||||
ThisY=MinY;
|
||||
|
||||
if (ThisY>MaxY)
|
||||
return(false);
|
||||
|
||||
ThisRect.SetXY(ThisX,ThisY);
|
||||
|
||||
if (!InColisionWithUsed(ThisRect))
|
||||
{
|
||||
RemovedFromUnused(ThisRect);
|
||||
AddToUsed(ThisRect);
|
||||
return(true);
|
||||
}
|
||||
|
||||
return(false);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function: TPRect VRAM::AllocVRAM(TPageType nType,int nW,int nH,bool Rotated)
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
class Predicate
|
||||
{
|
||||
public:
|
||||
bool operator()(TPRect const & R1,TPRect const & R2) const
|
||||
{
|
||||
u32 R1Val=(R1.H<<16)|(R1.W);
|
||||
u32 R2Val=(R2.H<<16)|(R2.W);
|
||||
return (R1Val<R2Val);
|
||||
}
|
||||
};
|
||||
|
||||
class Predicate2
|
||||
{
|
||||
public:
|
||||
bool operator()(TPRect const & R1,TPRect const & R2) const
|
||||
{
|
||||
u32 R1Val=(R1.H<<16)|(R1.W);
|
||||
u32 R2Val=(R2.H<<16)|(R2.W);
|
||||
return (R1Val>R2Val);
|
||||
}
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function: TPRect VRAM::AllocVRAM(TpRectVec & RectVec)
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
bool VRAM::AllocVRAM(TPRectVec & RectVec,bool nRotateEveryEmpty,bool nBig2Little,bool nWiderThanHigher)
|
||||
{
|
||||
int f;
|
||||
|
||||
RotateEveryEmpty=nRotateEveryEmpty;
|
||||
Big2Little=nBig2Little;
|
||||
WiderThanHigher=nWiderThanHigher;
|
||||
|
||||
if (WiderThanHigher)
|
||||
{
|
||||
for (f=0;f<RectVec.size();f++)
|
||||
{
|
||||
if ((RectVec[f].H > RectVec[f].W) && CanRotate(RectVec[f]))
|
||||
RectVec[f].SetRotate(!RectVec[f].GetRotate());
|
||||
}
|
||||
}
|
||||
|
||||
if (!Big2Little)
|
||||
std::sort(RectVec.begin(),RectVec.end(),Predicate());
|
||||
else
|
||||
std::sort(RectVec.begin(),RectVec.end(),Predicate2());
|
||||
|
||||
bool AllocedEverything=true;
|
||||
|
||||
for (f=0;f<RectVec.size();f++)
|
||||
{
|
||||
if (!AllocVRAM(RectVec[f]))
|
||||
{
|
||||
AllocedEverything=false;
|
||||
cout<<"Couldn't alloc "<<RectVec[f].W<<","<<RectVec[f].H<<endl;
|
||||
}
|
||||
}
|
||||
|
||||
return(AllocedEverything);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function: void VRAM::AllocVRAM(TPageType nType,int nW,int nH)
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
bool VRAM::AllocVRAM(TPRect & OriginalRect)
|
||||
{
|
||||
bool Done;
|
||||
TPRect ThisRect;
|
||||
|
||||
ThisRect=OriginalRect;
|
||||
|
||||
Done=false;
|
||||
|
||||
for (int Page=0;Page<NumOfTPages && !Done;Page++)
|
||||
{
|
||||
VecOfPages[Page].sort();
|
||||
|
||||
TPRect::SetAllocWH(ThisRect.W,ThisRect.H);
|
||||
|
||||
if (!TryNFit(VecOfPages[Page],ThisRect))
|
||||
{
|
||||
if (CanRotate(ThisRect))
|
||||
{
|
||||
ThisRect.SetRotate(!ThisRect.GetRotate());
|
||||
|
||||
VecOfPages[Page].sort();
|
||||
TPRect::SetAllocWH(ThisRect.W,ThisRect.H);
|
||||
|
||||
if (!TryNFit(VecOfPages[Page],ThisRect))
|
||||
ThisRect.SetRotate(!ThisRect.GetRotate());
|
||||
else
|
||||
Done=true;
|
||||
}
|
||||
}
|
||||
else
|
||||
Done=true;
|
||||
}
|
||||
|
||||
|
||||
if (Done)
|
||||
{
|
||||
OriginalRect=ThisRect;
|
||||
OriginalRect.SetAlloced(true);
|
||||
return(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
OriginalRect.SetAlloced(false);
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
bool VRAM::CanRotate(TPRect & ThisRect)
|
||||
{
|
||||
if (ThisRect.GetDontRotate())
|
||||
return(false);
|
||||
|
||||
switch (ThisRect.TypeOfPage)
|
||||
{
|
||||
case TP_PAL:
|
||||
return(false);
|
||||
|
||||
case TP_4:
|
||||
case TP_8:
|
||||
case TP_16:
|
||||
return(true);
|
||||
|
||||
case TP_SCREEN:
|
||||
case TP_NUM_OF_TP_TYPES:
|
||||
default:
|
||||
Error(ERR_FATAL,"Not catered for");
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function: void VRAM::AllocVRAM(TPageType nType,int nW,int nH)
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void VRAM::RectFromTpRect(Rect & R,TPRect const & ThisRect)
|
||||
{
|
||||
R.W=ThisRect.W;
|
||||
R.H=ThisRect.H;
|
||||
R.X=ThisRect.X;
|
||||
R.Y=ThisRect.Y;
|
||||
}
|
||||
|
||||
void VRAM::RemovedFromUnused(TPRect const & ThisRect)
|
||||
{
|
||||
RectVec Result;
|
||||
Rect NewRect;
|
||||
int f;
|
||||
|
||||
RectFromTpRect(NewRect,ThisRect);
|
||||
|
||||
int ColidedWith=0;
|
||||
|
||||
for ( f=0;f<Unused.size();f++)
|
||||
{
|
||||
Rect UnusedRect;
|
||||
|
||||
RectFromTpRect(UnusedRect,Unused[f]);
|
||||
|
||||
if (UnusedRect.IsColiding(ThisRect) )
|
||||
{
|
||||
CutRect(UnusedRect,ThisRect,Result);
|
||||
ColidedWith++;
|
||||
}
|
||||
else
|
||||
Result.push_back(UnusedRect);
|
||||
}
|
||||
|
||||
Unused.resize(0);
|
||||
|
||||
for (f=0;f<NumOfTPages;f++)
|
||||
VecOfPages[f].resize(0);
|
||||
|
||||
for (f=0;f<Result.size();f++)
|
||||
AddEmpty(Result[f].X,Result[f].Y,Result[f].W,Result[f].H);
|
||||
}
|
||||
|
||||
void VRAM::AddEmpty(int x,int y,int w,int h)
|
||||
{
|
||||
Unused.resize(Unused.size()+1);
|
||||
|
||||
TPRect & ThisRect=(Unused[Unused.size()-1]);
|
||||
|
||||
ThisRect.TypeOfPage=TP_4;
|
||||
ThisRect.W=w;
|
||||
ThisRect.H=h;
|
||||
ThisRect.X=x;
|
||||
ThisRect.Y=y;
|
||||
|
||||
int TpNum=(x/256)+((y/256)*VRAMWidthPages);
|
||||
|
||||
|
||||
|
||||
VecOfPages[TpNum].insert(VecOfPages[TpNum].end(),ThisRect);
|
||||
}
|
||||
|
||||
void VRAM::AddToUsed(TPRect const & ThisRect)
|
||||
{
|
||||
|
||||
Used.push_back(ThisRect);
|
||||
}
|
||||
|
||||
|
||||
bool VRAM::InColisionWithUsed(TPRect const & R)
|
||||
{
|
||||
for (int f=0;f<Used.size();f++)
|
||||
{
|
||||
if (R.IsColiding(Used[f]))
|
||||
return(true);
|
||||
}
|
||||
|
||||
return(false);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function: bool VRAM::CheckValidAlloc(TPageType nType,int nW,int nH)
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
bool VRAM::CheckValidAlloc(TPageType nType,int nW,int nH)
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function: int VRAM::GetMaxWidthTp(TPageType nType)
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
int VRAM::GetMaxWidthTp(TPageType nType)
|
||||
{
|
||||
int RetVal;
|
||||
|
||||
switch (nType)
|
||||
{
|
||||
case TP_4:
|
||||
RetVal=1;
|
||||
break;
|
||||
|
||||
case TP_8:
|
||||
RetVal=2;
|
||||
break;
|
||||
|
||||
case TP_16:
|
||||
RetVal=4;
|
||||
break;
|
||||
|
||||
case TP_SCREEN:
|
||||
RetVal=256;
|
||||
break;
|
||||
|
||||
default:
|
||||
RetVal=-1;
|
||||
Error(ERR_FATAL,"Illegal tpage type");
|
||||
break;
|
||||
}
|
||||
|
||||
return(RetVal);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function: int VRAM::GetXAlign(TPageType nType)
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
int VRAM::GetXAlign(TPageType nType)
|
||||
{
|
||||
int RetVal;
|
||||
|
||||
switch (nType)
|
||||
{
|
||||
case TP_4:
|
||||
RetVal=1;
|
||||
break;
|
||||
|
||||
case TP_8:
|
||||
RetVal=2;
|
||||
break;
|
||||
|
||||
case TP_16:
|
||||
RetVal=4;
|
||||
break;
|
||||
|
||||
case TP_PAL:
|
||||
RetVal=16*4;
|
||||
break;
|
||||
|
||||
case TP_SCREEN:
|
||||
RetVal=4;
|
||||
break;
|
||||
|
||||
default:
|
||||
RetVal=-1;
|
||||
Error(ERR_FATAL,"Illegal tpage type");
|
||||
break;
|
||||
}
|
||||
|
||||
return(RetVal);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
TPRect & VRAM::NewItem(TPRectVec & TPRects)
|
||||
{
|
||||
TPRects.resize(TPRects.size()+1);
|
||||
return(TPRects[TPRects.size()-1]);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
TPRect::TPRect(void)
|
||||
{
|
||||
InitRect();
|
||||
}
|
||||
|
||||
void TPRect::InitRect(void)
|
||||
{
|
||||
X=0;
|
||||
Y=0;
|
||||
W=0;
|
||||
H=0;
|
||||
TypeOfPage=TP_4;
|
||||
Rotated=false;
|
||||
Alloced=false;
|
||||
DontRotate=false;
|
||||
}
|
||||
|
||||
TPRect::TPRect(TPageType nType,int nW,int nH)
|
||||
{
|
||||
int WidthMul;
|
||||
|
||||
InitRect();
|
||||
|
||||
WidthMul=GetWidthMul(nType);
|
||||
|
||||
W=nW*WidthMul;
|
||||
H=nH;
|
||||
TypeOfPage=nType;
|
||||
}
|
||||
|
||||
int TPRect::GetWidthMul(TPageType nType)
|
||||
{
|
||||
int WidthMul;
|
||||
|
||||
switch (nType)
|
||||
{
|
||||
case TP_4:
|
||||
WidthMul=1;
|
||||
break;
|
||||
|
||||
case TP_8:
|
||||
WidthMul=2;
|
||||
break;
|
||||
|
||||
case TP_16:
|
||||
case TP_SCREEN:
|
||||
case TP_PAL:
|
||||
WidthMul=4;
|
||||
break;
|
||||
|
||||
case TP_NUM_OF_TP_TYPES:
|
||||
default:
|
||||
Error(ERR_FATAL,"Can't alloc type TP_NUM_OF_TP_TYPES");
|
||||
break;
|
||||
}
|
||||
return (WidthMul);
|
||||
}
|
||||
|
||||
void TPRect::Set(TPageType nType,int nX,int nY,int nW,int nH)
|
||||
{
|
||||
TypeOfPage=nType;
|
||||
X=nX;
|
||||
Y=nY;
|
||||
W=nW*GetWidthMul(nType);
|
||||
H=nH;
|
||||
}
|
||||
|
||||
void TPRect::SetXY(int nX,int nY)
|
||||
{
|
||||
X=nX;
|
||||
Y=nY;
|
||||
}
|
||||
|
||||
u32 TPRect::GetId(void) const
|
||||
{
|
||||
int Colis=0;
|
||||
|
||||
int PageNum=(X/256)+((Y/256)*16);
|
||||
|
||||
if ((X/256) != ((X+W2Alloc-1)/256))
|
||||
Colis|=1;
|
||||
|
||||
if ((Y/256) != ((Y+H2Alloc-1)/256))
|
||||
Colis|=2;
|
||||
|
||||
return ((Colis<<24)|(PageNum<<16)|((Y&0xff)<<8)|(X&0xff));
|
||||
}
|
||||
|
||||
bool TPRect::SetRotate(bool Rot)
|
||||
{
|
||||
bool RetBool=Rotated;
|
||||
|
||||
if (Rot != RetBool)
|
||||
{
|
||||
W/=GetWidthMul(TypeOfPage);
|
||||
int Temp=W;
|
||||
W=H;
|
||||
H=Temp;
|
||||
W*=GetWidthMul(TypeOfPage);
|
||||
}
|
||||
|
||||
Rotated=Rot;
|
||||
return(RetBool);
|
||||
}
|
||||
|
||||
|
||||
void VRAM::getUnusedSpace(TPRectVec & unusedBoxes)
|
||||
{
|
||||
int vX=X;
|
||||
int vY=Y;
|
||||
const int Width16=256;
|
||||
const int Height16=256;
|
||||
|
||||
for (int y=0;y<VRAMHeightPages;y++)
|
||||
for (int x=0;x<VRAMWidthPages;x++)
|
||||
{
|
||||
TPRect thisRect;
|
||||
bool foundRect;
|
||||
|
||||
foundRect=false;
|
||||
|
||||
for (int f=1;f<255 && !foundRect;f++)
|
||||
{
|
||||
int boxBaseY;
|
||||
int boxHeight;
|
||||
|
||||
boxBaseY=f;
|
||||
boxHeight=255-f;
|
||||
|
||||
thisRect.X=(x*Width16)+vX;
|
||||
thisRect.Y=(y*Height16)+vY+boxBaseY;
|
||||
thisRect.W=Width16;
|
||||
thisRect.H=boxHeight;
|
||||
|
||||
if (!InColisionWithUsed(thisRect))
|
||||
foundRect=true;
|
||||
}
|
||||
|
||||
if (foundRect)
|
||||
unusedBoxes.push_back(thisRect);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int VRAM::GetNumOfUsedPages()
|
||||
{
|
||||
int Used=0;
|
||||
int vX=X;
|
||||
int vY=Y;
|
||||
const int Width16=256;
|
||||
const int Height16=256;
|
||||
|
||||
for (int y=0;y<VRAMHeightPages;y++)
|
||||
for (int x=0;x<VRAMWidthPages;x++)
|
||||
{
|
||||
TPRect ThisRect;
|
||||
ThisRect.X=(x*Width16)+vX;
|
||||
ThisRect.Y=(y*Height16)+vY;
|
||||
ThisRect.W=Width16;
|
||||
ThisRect.H=Height16;
|
||||
|
||||
if (InColisionWithUsed(ThisRect))
|
||||
Used++;
|
||||
}
|
||||
return(Used);
|
||||
}
|
||||
|
||||
|
||||
bool TPRect::IsAlloced(void) const
|
||||
{
|
||||
return(Alloced);
|
||||
}
|
||||
|
||||
void TPRect::SetAlloced(bool nAlloced)
|
||||
{
|
||||
Alloced=nAlloced;
|
||||
}
|
||||
|
||||
int VRAM::GetNumOfItems()
|
||||
{
|
||||
return(Used.size());
|
||||
}
|
||||
|
||||
void TPRect::InitFromFrame(Frame const & Fr)
|
||||
{
|
||||
/* !!!!! Make this support other bit widths */
|
||||
|
||||
W=Fr.GetWidth();
|
||||
H=Fr.GetHeight();
|
||||
|
||||
if (Fr.GetNumOfCols() <= 16)
|
||||
TypeOfPage=TP_4;
|
||||
else if (Fr.GetNumOfCols() <= 256)
|
||||
TypeOfPage=TP_8;
|
||||
else
|
||||
Error(ERR_FATAL,"Only 4 & 8 bit supported right now");
|
||||
|
||||
W*=GetWidthMul(TypeOfPage);
|
||||
}
|
||||
|
||||
|
||||
TPageType TPRect::convertTo16Bit(void)
|
||||
{
|
||||
TPageType oldType;
|
||||
|
||||
switch (TypeOfPage)
|
||||
{
|
||||
case TP_4:
|
||||
// W=GU_AlignVal(W,4)/4;
|
||||
break;
|
||||
|
||||
case TP_8:
|
||||
// W=GU_AlignVal(W,2)/2;
|
||||
break;
|
||||
default:
|
||||
Error(ERR_FATAL,"Only 4 & 8 bit supported right now");
|
||||
break;
|
||||
}
|
||||
|
||||
oldType=TypeOfPage;
|
||||
TypeOfPage=TP_16;
|
||||
|
||||
return(oldType);
|
||||
}
|
||||
|
||||
void TPRect::convertFrom16Bit(TPageType newType)
|
||||
{
|
||||
switch (newType)
|
||||
{
|
||||
case TP_4:
|
||||
// W=W*4;
|
||||
break;
|
||||
|
||||
case TP_8:
|
||||
// W=W*2;
|
||||
break;
|
||||
default:
|
||||
Error(ERR_FATAL,"Only 4 & 8 bit supported right now");
|
||||
break;
|
||||
}
|
||||
|
||||
TypeOfPage=newType;
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
||||
|
||||
|
260
Utils/parkgrab/tpage.h
Normal file
260
Utils/parkgrab/tpage.h
Normal file
|
@ -0,0 +1,260 @@
|
|||
/*=========================================================================
|
||||
|
||||
FILENAME.CPP
|
||||
|
||||
Author: Gary Liddon @
|
||||
Created:
|
||||
Project:
|
||||
Purpose:
|
||||
|
||||
Copyright (c) 1997 Climax Development Ltd
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
#ifndef __TPAGE_HPP__
|
||||
#define __TPAGE_HPP__
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Includes
|
||||
-------- */
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
#include <list>
|
||||
|
||||
/* Glib
|
||||
---- */
|
||||
#include <frame.hpp>
|
||||
|
||||
/* Local
|
||||
----- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Tyepdefs && Defines
|
||||
------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Structure defintions
|
||||
-------------------- */
|
||||
struct POS_INFO
|
||||
{
|
||||
int MinXTp; /* Minimum x placeable within a Tpage */
|
||||
int MaxXTp; /* Maximum x placeable within a Tpage */
|
||||
|
||||
int MinYTp; /* Minimum y placeable within a Tpage */
|
||||
int MaxYTp; /* Maximum y placeable within a Tpage */
|
||||
|
||||
int MinX; /* Minimum global x */
|
||||
int MaxX; /* Maximum global x */
|
||||
|
||||
int MinY; /* Minimum global y */
|
||||
int MaxY; /* Maximum global y */
|
||||
|
||||
int XAlign; /* X Alignment */
|
||||
int TpWidthPix; /* Width of each tpages for this rect */
|
||||
};
|
||||
|
||||
|
||||
/* Different Tpage Types
|
||||
--------------------- */
|
||||
enum TPageType
|
||||
{
|
||||
TP_4= 0,
|
||||
TP_8,
|
||||
TP_16,
|
||||
TP_SCREEN,
|
||||
TP_PAL,
|
||||
TP_NUM_OF_TP_TYPES,
|
||||
};
|
||||
|
||||
|
||||
/* A Rectangle in the Tpage
|
||||
------------------------ */
|
||||
class TPRect : public Rect
|
||||
{
|
||||
public:
|
||||
TPRect(void);
|
||||
TPRect(TPageType nType,int nW,int nH);
|
||||
TPRect(TPRect const & NewR) {MakeCopy(NewR);}
|
||||
|
||||
void InitFromFrame(Frame const & Fr);
|
||||
void SetAlloced(bool nAlloced=true);
|
||||
bool SetRotate(bool Rot=true);
|
||||
void operator=(TPRect const & NewR) {MakeCopy(NewR);}
|
||||
bool operator< (TPRect const & R) const {return(GetId()<R.GetId());}
|
||||
void SetWH(int nW,int nH)
|
||||
{W=nW;H=nH;}
|
||||
|
||||
void SetXY(int nX,int nY);
|
||||
void Set(TPageType nType,int nX,int nY,int nW,int nH);
|
||||
void SetTpType(TPageType nType) {TypeOfPage=nType;}
|
||||
|
||||
bool GetRotate(void) const {return(Rotated);}
|
||||
bool IsAlloced(void) const;
|
||||
int GetTpageIn(void) const;
|
||||
u32 GetId(void) const;
|
||||
bool GetAlloced(void){return(Alloced);}
|
||||
|
||||
static void SetAllocWH(int nW,int nH) {W2Alloc=nW; H2Alloc=nH;}
|
||||
|
||||
|
||||
TPageType convertTo16Bit(void);
|
||||
void convertFrom16Bit(TPageType newType);
|
||||
|
||||
|
||||
void SetId(int NewId)
|
||||
{Id=NewId;}
|
||||
|
||||
int GetId(void)
|
||||
{return(Id);}
|
||||
|
||||
TPageType TypeOfPage;
|
||||
|
||||
void SetDontRotate(bool NewVal=true) {DontRotate=NewVal;}
|
||||
bool GetDontRotate(void) const {return(DontRotate);}
|
||||
|
||||
protected:
|
||||
int GetWidthMul(TPageType nType);
|
||||
void InitRect(void);
|
||||
|
||||
bool Rotated;
|
||||
int Id;
|
||||
|
||||
void MakeCopy(TPRect const & NewR)
|
||||
{
|
||||
W=NewR.W;
|
||||
H=NewR.H;
|
||||
X=NewR.X;
|
||||
Y=NewR.Y;
|
||||
TypeOfPage=NewR.TypeOfPage;
|
||||
Rotated=NewR.Rotated;
|
||||
Id=NewR.Id;
|
||||
Alloced=NewR.Alloced;
|
||||
DontRotate=NewR.DontRotate;
|
||||
}
|
||||
|
||||
static int W2Alloc;
|
||||
static int H2Alloc;
|
||||
|
||||
bool Alloced;
|
||||
bool DontRotate;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/* VRAM Alloc handle
|
||||
----------------- */
|
||||
typedef int VHND;
|
||||
typedef std::vector<TPRect> TPRectVec;
|
||||
|
||||
/* VRAM
|
||||
---- */
|
||||
|
||||
typedef std::list<TPRect> TPRectList;
|
||||
typedef std::vector<TPRectList> TPRectListVec;
|
||||
|
||||
class VRAM : public GObject
|
||||
{
|
||||
public:
|
||||
VRAM(int nTpWidth=16,int nTpHeightInPixels=512);
|
||||
|
||||
int GetNumOfItems(void);
|
||||
int GetNumOfUsedPages();
|
||||
|
||||
bool AllocVRAM(TPRect & OriginalRect);
|
||||
bool AllocVRAM(TPRectVec & RectVec,bool nRotateEveryEmpty,bool nBig2Little,bool nWiderThanHigher);
|
||||
|
||||
TPRect const & GetVRAM(VHND hnd) const;
|
||||
|
||||
TPRectVec & GetUsed(void)
|
||||
{return(Used);}
|
||||
|
||||
TPRectVec & GetUnused(void)
|
||||
{return(Unused);}
|
||||
|
||||
void Clear(int nTpWidth=-1,int nTpHeight=-1);
|
||||
|
||||
void SetBig2Little(bool Val=true)
|
||||
{ Big2Little=Val;}
|
||||
|
||||
void SetRotateEveryEmpty(bool Val=true)
|
||||
{ RotateEveryEmpty=Val;}
|
||||
|
||||
bool CanRotate(TPRect & ThisRect);
|
||||
|
||||
void getUnusedSpace(TPRectVec & unusedBoxes);
|
||||
|
||||
protected:
|
||||
void PosFromTPrect(TPRect & ThisRect,POS_INFO & Pi);
|
||||
bool TryRect(TPRect & BlankRect,TPRect & ThisRect);
|
||||
|
||||
TPRectListVec VecOfPages;
|
||||
|
||||
bool TryNFit(TPRectList & TpList,TPRect & ThisRect);
|
||||
|
||||
void AddEmpty(int x,int y,int w,int h);
|
||||
bool InColisionWithUsed(TPRect const & R);
|
||||
void InitEmpty(int vX,int vY,int W,int H);
|
||||
bool CheckValidAlloc(TPageType nType,int nW,int nH);
|
||||
int GetXAlign(TPageType nType);
|
||||
int GetMaxWidthTp(TPageType nType);
|
||||
void RemovedFromUnused(TPRect const & ThisRect);
|
||||
void AddToUsed(TPRect const & ThisRect);
|
||||
void RectFromTpRect(Rect & R,TPRect const & ThisRect);
|
||||
|
||||
TPRect & NewItem(TPRectVec & TPRects);
|
||||
|
||||
TPRect & NewUnused(void)
|
||||
{ return(NewItem(Unused)); }
|
||||
|
||||
TPRect & NewUsed(void)
|
||||
{ return(NewItem(Used)); }
|
||||
|
||||
|
||||
TPRectVec Unused;
|
||||
TPRectVec Used;
|
||||
TPRect ErrorRect;
|
||||
|
||||
int X,Y,W,H;
|
||||
int NumOfTPages;
|
||||
int TpWidth;
|
||||
int TpHeightInPixels;
|
||||
|
||||
int VRAMWidthPages;
|
||||
int VRAMHeightPages;
|
||||
|
||||
bool Big2Little;
|
||||
bool RotateEveryEmpty;
|
||||
bool WiderThanHigher;
|
||||
};
|
||||
|
||||
/* Error codes for VHND
|
||||
-------------------- */
|
||||
enum
|
||||
{
|
||||
VHND_NULL = -1,
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Globals
|
||||
------- */
|
||||
|
||||
/* Vars
|
||||
---- */
|
||||
|
||||
/* Data
|
||||
---- */
|
||||
|
||||
/* Functions
|
||||
--------- */
|
||||
void TestTPageStuff(void);
|
||||
|
||||
/*---------------------------------------------------------------------- */
|
||||
|
||||
#endif /* __TPAGE_HPP__ */
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
||||
|
||||
|
103
Utils/parkgrab/vimage.h
Normal file
103
Utils/parkgrab/vimage.h
Normal file
|
@ -0,0 +1,103 @@
|
|||
/*=========================================================================
|
||||
|
||||
VIMAGE.CPP
|
||||
|
||||
Author: Gary Liddon @ Climax
|
||||
Created:
|
||||
Project: TPW Parkgrab
|
||||
Purpose: An object that represents a bit of VRAM
|
||||
|
||||
Copyright (c) 1998 G R Liddon
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
#ifndef __VIMAGE_H__
|
||||
#define __VIMAGE_H__
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Includes
|
||||
-------- */
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
|
||||
/* Glib
|
||||
---- */
|
||||
#include <gobject.hpp>
|
||||
#include <fstream>
|
||||
|
||||
/* Local
|
||||
----- */
|
||||
#include "sprset.h"
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Tyepdefs && Defines
|
||||
------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Structure defintions
|
||||
-------------------- */
|
||||
|
||||
class VRAMImage : protected GObject
|
||||
{
|
||||
public:
|
||||
|
||||
VRAMImage(int NewWidthInTpages,int NewHeightInPixels);
|
||||
~VRAMImage(void);
|
||||
|
||||
void WriteInTpageChunks(std::ofstream & Str);
|
||||
void Write(std::ofstream & Str);
|
||||
void PlotPal(SprPal const & PalToPlot);
|
||||
void PlotFrame(SprFrame const & FrameToPlot);
|
||||
void SaveAs16ColLbm(const char * Name);
|
||||
|
||||
void setDoCompress(bool newVal)
|
||||
{m_doCompress=newVal;}
|
||||
|
||||
bool getDoCompress(void) const
|
||||
{return(m_doCompress);}
|
||||
|
||||
void getTpData(unsigned int tp,std::vector<u8> & dest) const;
|
||||
|
||||
protected:
|
||||
void PlotFrame4(SprFrame const & Fr);
|
||||
void PlotFrame8(SprFrame const & Fr);
|
||||
u16 GetPsxCol(Colour const & Col) const;
|
||||
|
||||
int WidthInBytes;
|
||||
int WidthInTpages;
|
||||
int HeightInTPages;
|
||||
int HeightInPixels;
|
||||
int aTPageHeight;
|
||||
int TPageSizeInBytes;
|
||||
int VramAreaBytes;
|
||||
bool m_doCompress;
|
||||
|
||||
u8 * lbmData;
|
||||
u8 * VRAMData;
|
||||
};
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Globals
|
||||
------- */
|
||||
|
||||
/* Vars
|
||||
---- */
|
||||
|
||||
/* Data
|
||||
---- */
|
||||
|
||||
/* Functions
|
||||
--------- */
|
||||
|
||||
/*---------------------------------------------------------------------- */
|
||||
|
||||
#else /* __VIMAGE_H__ */
|
||||
|
||||
class VRAMImage;
|
||||
|
||||
#endif
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
1022
Utils/transtext/kanjiclass.cpp
Normal file
1022
Utils/transtext/kanjiclass.cpp
Normal file
File diff suppressed because it is too large
Load diff
97
Utils/transtext/kanjiclass.h
Normal file
97
Utils/transtext/kanjiclass.h
Normal file
|
@ -0,0 +1,97 @@
|
|||
/*=========================================================================
|
||||
|
||||
KANJICLASS.CPP
|
||||
|
||||
Author: Gary Liddon @
|
||||
Created:
|
||||
Project:
|
||||
Purpose:
|
||||
|
||||
Copyright (c) 1998 G R Liddon
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
#ifndef __KANJI_CLASS__
|
||||
#define __KANJI_CLASS__
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Includes
|
||||
-------- */
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
#include <vector>
|
||||
|
||||
/* Glib
|
||||
---- */
|
||||
#include <gtypes.h>
|
||||
#include <gobject.hpp>
|
||||
|
||||
/* Local
|
||||
----- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Tyepdefs && Defines
|
||||
------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Structure defintions
|
||||
-------------------- */
|
||||
|
||||
class KanjiClass : GObject
|
||||
{
|
||||
public:
|
||||
|
||||
enum KanjiFontSize
|
||||
{
|
||||
FONT_SIZE_11,
|
||||
FONT_SIZE_13,
|
||||
FONT_SIZE_15,
|
||||
};
|
||||
private:
|
||||
std::vector<u8> m_kanjiHit;
|
||||
|
||||
void initialise(void);
|
||||
|
||||
void addKanjiHit(uint hi,uint lo);
|
||||
bool getKanjiHit(uint hi,uint lo);
|
||||
void clearKanjiHit(uint hi,uint lo);
|
||||
int findKanjiIndex(u16 kan) const;
|
||||
static void saveKanjiLbm(char const * fileName,KanjiFontSize k,u16 kan);
|
||||
|
||||
public:
|
||||
|
||||
|
||||
KanjiClass(void);
|
||||
|
||||
void addStr(u8 const * newStr);
|
||||
|
||||
int howManyKanjiChars(void);
|
||||
void saveKanjiLbms(char const * dir,KanjiFontSize k = KanjiClass::FONT_SIZE_11);
|
||||
void saveKanjiLbmNames(char const * dir,char const *name);
|
||||
void saveKanjiTable(char const *name);
|
||||
static void writeEnglishFontLbms(char const * dir,KanjiFontSize k = KanjiClass::FONT_SIZE_11,char const * repFile= NULL);
|
||||
};
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Globals
|
||||
------- */
|
||||
|
||||
/* Vars
|
||||
---- */
|
||||
|
||||
/* Data
|
||||
---- */
|
||||
|
||||
/* Functions
|
||||
--------- */
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------- */
|
||||
|
||||
#endif /* XYZ */
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
299
Utils/transtext/main.cpp
Normal file
299
Utils/transtext/main.cpp
Normal file
|
@ -0,0 +1,299 @@
|
|||
/*=========================================================================
|
||||
|
||||
MAIN.CPP
|
||||
|
||||
Author: Gary Liddon @ Fareham
|
||||
Created: 3rd March 1999
|
||||
Project: Theme Park World Playstation
|
||||
Purpose: Main module for Folio
|
||||
|
||||
Copyright (c) 1998 G R Liddon
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Includes
|
||||
-------- */
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
#include <vector>
|
||||
#include <conio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/utime.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
|
||||
/* Glib
|
||||
---- */
|
||||
#include <misc.hpp>
|
||||
#include <gfname.hpp>
|
||||
#include <gstring.hpp>
|
||||
#include <pcre.h>
|
||||
|
||||
/* tplib
|
||||
---- */
|
||||
#include <trans.h>
|
||||
#include <lang.h>
|
||||
#include <script.h>
|
||||
|
||||
|
||||
/* local
|
||||
---- */
|
||||
#include "kanjiclass.h"
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Version info
|
||||
|
||||
1.0 - 1.2 GL Initial working version
|
||||
1.3 GL Longer line length (now 4096)
|
||||
1.4 GL Added comments to file
|
||||
1.5 GL Changed it so that \n are now returns
|
||||
1.6 GL Added a slew of stuff to handle kanji
|
||||
1.7 GL Chganged format of kanji table
|
||||
1.8 GL Removed bug with kanji frame lookup
|
||||
1.9 GL added -s so user can specify the size of output font
|
||||
1.91 GL Transtext also writes out an ID text file (id.dat)
|
||||
1.92 GL fixed bug with output kanji table being too short
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Tyepdefs && Defines
|
||||
------------------- */
|
||||
using namespace std;
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Structure defintions
|
||||
-------------------- */
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function Prototypes
|
||||
------------------- */
|
||||
static void usage(void);
|
||||
static char * cycleCommands(char *String,int Num);
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Vars
|
||||
---- */
|
||||
static const float version=1.92f;
|
||||
static GString fileWithTranslations;
|
||||
static GString headerFile;
|
||||
static GString outDir;
|
||||
|
||||
static GString g_japKanjiFile;
|
||||
static GString g_japLbmDir;
|
||||
static GString g_englishLbmsDir;
|
||||
static GString g_japLbmListFile;
|
||||
static int g_fontSize=0;
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Data
|
||||
---- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
cerr<<"GRLiddon() TRANSTEXT text translation stuphh "<<version<<endl;
|
||||
cerr<<"Copyright (c) 1999 G R Liddon. All rights reserved"<<endl<<endl;
|
||||
|
||||
if (argc==1)
|
||||
usage();
|
||||
else
|
||||
{
|
||||
CommandLine(argc,argv,cycleCommands);
|
||||
|
||||
if (g_englishLbmsDir)
|
||||
{
|
||||
KanjiClass::writeEnglishFontLbms(g_englishLbmsDir,KanjiClass::KanjiFontSize(g_fontSize));
|
||||
}
|
||||
|
||||
if (fileWithTranslations)
|
||||
{
|
||||
AllTextDatabases myDatabases;
|
||||
myDatabases.readTranslationFile(fileWithTranslations);
|
||||
|
||||
if (outDir)
|
||||
myDatabases.write(outDir);
|
||||
|
||||
if (headerFile)
|
||||
myDatabases.writeHeaderFile(headerFile);
|
||||
|
||||
|
||||
/* Do some kanji jiggery pokery */
|
||||
|
||||
|
||||
if (g_japKanjiFile || g_japLbmDir || g_japLbmListFile)
|
||||
{
|
||||
TextDatabase * jDataBase;
|
||||
int numOfStrings;
|
||||
KanjiClass kClass;
|
||||
|
||||
jDataBase=myDatabases.getTextDataBase(JAPANESE);
|
||||
numOfStrings=jDataBase->getNumOfStrings();
|
||||
|
||||
for (int f=0;f<numOfStrings;f++)
|
||||
kClass.addStr((u8 const*)jDataBase->getText(f));
|
||||
|
||||
if (g_japLbmDir)
|
||||
{
|
||||
if (g_fontSize >=0 && g_fontSize < 3)
|
||||
kClass.saveKanjiLbms(g_japLbmDir,KanjiClass::KanjiFontSize(g_fontSize));
|
||||
else
|
||||
GObject::Error(ERR_FATAL,"illegal font size parameter");
|
||||
}
|
||||
|
||||
if (g_japKanjiFile)
|
||||
kClass.saveKanjiTable(g_japKanjiFile);
|
||||
|
||||
if (g_japLbmListFile && g_japLbmDir)
|
||||
kClass.saveKanjiLbmNames(g_japLbmDir,g_japLbmListFile);
|
||||
|
||||
cout<<"text uses "<<kClass.howManyKanjiChars()<<endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
GObject::Error(ERR_FATAL,"you must define a translation file");
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function: void Usage(void)
|
||||
Notes: Usage of the util
|
||||
---------------------------------------------------------------------- */
|
||||
void usage(void)
|
||||
{
|
||||
cout<<"Usage: TRANSTEXT <in file> [ switches.. ]\n";
|
||||
cout<<"Switches:\n"<<endl;
|
||||
cout<<"-o:<dir> Dir to save translation strings to"<<endl;
|
||||
cout<<"-e:<dir> Dir write ascii images to"<<endl;
|
||||
cout<<"-h:<file> File to save lang enums to"<<endl;
|
||||
cout<<endl;
|
||||
cout<<"-d:<dir> Dir to save kanji lbms to"<<endl;
|
||||
cout<<"-j:<file> File to save kanji table to"<<endl;
|
||||
cout<<"-p:<file> File to save list of saved lbms to"<<endl;
|
||||
cout<<endl;
|
||||
cout<<"-s:<0|1|2> Set the size of the output font"<<endl;
|
||||
cout<<endl;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
---------------------------------------------------------------------- */
|
||||
GString getFileString(char const * Switch)
|
||||
{
|
||||
pcre * MyPattern;
|
||||
int Matches;
|
||||
const int NumOfOffsets=20;
|
||||
int Offsets[NumOfOffsets];
|
||||
char const * ErrTxt;
|
||||
int ErrNum;
|
||||
char SwitchText[100];
|
||||
|
||||
MyPattern=pcre_compile("^-.:(.*)",0,&ErrTxt,&ErrNum,NULL);
|
||||
Matches=pcre_exec(MyPattern,NULL,Switch,strlen(Switch),0,Offsets,NumOfOffsets);
|
||||
|
||||
if (Matches != 2)
|
||||
GObject::Error(ERR_FATAL,"Ill formatted switch %s",Switch);
|
||||
|
||||
memcpy(SwitchText,&Switch[Offsets[2]],Offsets[3]-Offsets[2]);
|
||||
SwitchText[Offsets[3]-Offsets[2]]=0;
|
||||
|
||||
return(GString(SwitchText));
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
---------------------------------------------------------------------- */
|
||||
bool getPlusMinus(char const * Switch)
|
||||
{
|
||||
pcre * MyPattern;
|
||||
int Matches;
|
||||
const int NumOfOffsets=20;
|
||||
int Offsets[NumOfOffsets];
|
||||
char const * ErrTxt;
|
||||
int ErrNum;
|
||||
|
||||
MyPattern=pcre_compile("^-.([+|-])",0,&ErrTxt,&ErrNum,NULL);
|
||||
Matches=pcre_exec(MyPattern,NULL,Switch,strlen(Switch),0,Offsets,NumOfOffsets);
|
||||
|
||||
if (Matches != 2)
|
||||
GObject::Error(ERR_FATAL,"Ill formatted switch %s",Switch);
|
||||
|
||||
return(Switch[Offsets[2]]=='+');
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function: char *CycleCommands(char *String,int Num)
|
||||
Purpose: Callback to cycle through command line items
|
||||
Params: String = Text of item
|
||||
Num = Item number
|
||||
---------------------------------------------------------------------- */
|
||||
char * cycleCommands(char * cmdString,int num)
|
||||
{
|
||||
if (cmdString[0]=='-' || cmdString[0]=='/')
|
||||
{
|
||||
switch (cmdString[1])
|
||||
{
|
||||
case 'e':
|
||||
g_englishLbmsDir=getFileString(cmdString);
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
headerFile=getFileString(cmdString);
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
outDir=getFileString(cmdString);
|
||||
break;
|
||||
|
||||
case 'j':
|
||||
g_japKanjiFile=getFileString(cmdString);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
g_japLbmDir=getFileString(cmdString);
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
g_japLbmListFile=getFileString(cmdString);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
g_fontSize=atoi(getFileString(cmdString));
|
||||
break;
|
||||
|
||||
default:
|
||||
GObject::Error(ERR_FATAL,"unknown switch %s",cmdString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fileWithTranslations)
|
||||
GObject::Error(ERR_FATAL,"translation file already defined as %s",(char const *)fileWithTranslations);
|
||||
else
|
||||
fileWithTranslations=cmdString;
|
||||
}
|
||||
|
||||
return(cmdString);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
336
Utils/transtext/script.cpp
Normal file
336
Utils/transtext/script.cpp
Normal file
|
@ -0,0 +1,336 @@
|
|||
/*=========================================================================
|
||||
|
||||
FILENAME.CPP
|
||||
|
||||
Author: Gary Liddon @
|
||||
Created:
|
||||
Project:
|
||||
Purpose:
|
||||
|
||||
Copyright (c) 1998 G R Liddon
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Includes
|
||||
-------- */
|
||||
|
||||
#include "script.h"
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
|
||||
/* Glib
|
||||
---- */
|
||||
|
||||
/* Local
|
||||
----- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Tyepdefs && Defines
|
||||
------------------- */
|
||||
using namespace std;
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Structure defintions
|
||||
-------------------- */
|
||||
const int DEFAULT_LINE_LENGTH=8192;
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function Prototypes
|
||||
------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Vars
|
||||
---- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Data
|
||||
---- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
ScriptFile::ScriptFile(void)
|
||||
{
|
||||
m_isOpen=false;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
ScriptFile::~ScriptFile(void)
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void ScriptFile::close(void)
|
||||
{
|
||||
if (m_isOpen)
|
||||
m_inStream.close();
|
||||
|
||||
m_isOpen=false;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void ScriptFile::open(char const * fileName)
|
||||
{
|
||||
if (m_isOpen)
|
||||
close();
|
||||
|
||||
m_inStream.open(fileName,ios::binary|ios::in);
|
||||
|
||||
if (m_inStream)
|
||||
{
|
||||
m_fileName=fileName;
|
||||
|
||||
}
|
||||
else
|
||||
GObject::Error(ERR_FATAL,"unable to open script file %s",fileName);
|
||||
|
||||
m_isOpen=true;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void ScriptFile::scriptError(void)
|
||||
{
|
||||
GObject::Error(ERR_FATAL,"Ill formatted script file %s, line %d",(char const *)m_fileName,m_lineCount);
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function: ak
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void ScriptFile::checkIsOpen(void)
|
||||
{
|
||||
if (!m_isOpen)
|
||||
GObject::Error(ERR_FATAL,"file operation needed by ScriptFile but no file is open");
|
||||
}
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
bool ScriptFile::getNextNonBlankLine(char * line,int lineLen)
|
||||
{
|
||||
checkIsOpen();
|
||||
|
||||
do
|
||||
{
|
||||
if (m_inStream.eof())
|
||||
return(false);
|
||||
|
||||
m_inStream.getline(line,lineLen);
|
||||
|
||||
|
||||
int lineLength;
|
||||
|
||||
lineLength=strlen(line);
|
||||
|
||||
for (int f=0;f<lineLength;f++)
|
||||
{
|
||||
if (line[f] == ';')
|
||||
line[f]=0;
|
||||
}
|
||||
|
||||
if (strlen(line))
|
||||
line[strlen(line)-1]=0;
|
||||
|
||||
m_lineCount++;
|
||||
|
||||
// stripTrailingSpace(line);
|
||||
}
|
||||
while (!strlen(line));
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
bool ScriptFile::nextLineIsCommand(void)
|
||||
{
|
||||
checkIsOpen();
|
||||
|
||||
bool retVal;
|
||||
streampos thisPos;
|
||||
const int lineLength=DEFAULT_LINE_LENGTH;
|
||||
char line[lineLength];
|
||||
int oldLineCount;
|
||||
|
||||
oldLineCount=m_lineCount;
|
||||
|
||||
retVal=false;
|
||||
|
||||
thisPos=m_inStream.tellg();
|
||||
|
||||
if (getNextNonBlankLine(line,lineLength))
|
||||
{
|
||||
stripTrailingSpace(line);
|
||||
retVal=isCommand(line);
|
||||
}
|
||||
|
||||
m_inStream.seekg(thisPos);
|
||||
|
||||
m_lineCount=oldLineCount;
|
||||
|
||||
return(retVal);
|
||||
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
GString ScriptFile::peekNextCommand(void)
|
||||
{
|
||||
checkIsOpen();
|
||||
|
||||
GString retStr;
|
||||
|
||||
if (nextLineIsCommand())
|
||||
{
|
||||
const int lineLength=DEFAULT_LINE_LENGTH;
|
||||
char line[lineLength];
|
||||
int oldLineCount;
|
||||
streampos thisPos;
|
||||
|
||||
oldLineCount=m_lineCount;
|
||||
|
||||
thisPos=m_inStream.tellg();
|
||||
|
||||
getNextNonBlankLine(line,lineLength);
|
||||
stripTrailingSpace(line);
|
||||
retStr=getCommandString(line);
|
||||
|
||||
m_inStream.seekg(thisPos);
|
||||
|
||||
m_lineCount=oldLineCount;
|
||||
}
|
||||
|
||||
return(retStr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void ScriptFile::stripTrailingSpace(char * line)
|
||||
{
|
||||
if (strlen(line))
|
||||
{
|
||||
bool done=false;
|
||||
|
||||
|
||||
for (int f=strlen(line)-1;f<=0 && !done ;f--)
|
||||
{
|
||||
if ((!isspace(line[f])) )
|
||||
done=true;
|
||||
else
|
||||
line[f]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
GString ScriptFile::getCommandString(char * com)
|
||||
{
|
||||
char * newStr;
|
||||
|
||||
newStr=strdup(com);
|
||||
|
||||
newStr[strlen(newStr)-1]=0;
|
||||
GString retStr(&newStr[1]);
|
||||
|
||||
free(newStr);
|
||||
|
||||
return(retStr);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
bool ScriptFile::isCommand(char * line)
|
||||
{
|
||||
return ((line[0]=='[') && (line[strlen(line)-1]==']'));
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
GString ScriptFile::getNextLine(void)
|
||||
{
|
||||
const int lineLength=DEFAULT_LINE_LENGTH;
|
||||
char line[lineLength];
|
||||
|
||||
getNextNonBlankLine(line,lineLength);
|
||||
|
||||
return(line);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
bool ScriptFile::eof(void)
|
||||
{
|
||||
checkIsOpen();
|
||||
return(m_inStream.eof());
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
95
Utils/transtext/script.h
Normal file
95
Utils/transtext/script.h
Normal file
|
@ -0,0 +1,95 @@
|
|||
/*=========================================================================
|
||||
|
||||
FILENAME.CPP
|
||||
|
||||
Author: Gary Liddon @
|
||||
Created:
|
||||
Project:
|
||||
Purpose:
|
||||
|
||||
Copyright (c) 1998 G R Liddon
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
#ifndef __SCRIPT_H__
|
||||
#define __SCRIPT_H__
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Includes
|
||||
-------- */
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
#include <fstream>
|
||||
|
||||
/* Glib
|
||||
---- */
|
||||
#include <gstring.hpp>
|
||||
|
||||
/* Local
|
||||
----- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Tyepdefs && Defines
|
||||
------------------- */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Structure defintions
|
||||
-------------------- */
|
||||
class ScriptFile
|
||||
{
|
||||
private:
|
||||
std::ifstream m_inStream;
|
||||
bool m_isOpen;
|
||||
GString m_fileName;
|
||||
int m_lineCount;
|
||||
|
||||
void scriptError(void);
|
||||
|
||||
bool getNextNonBlankLine(char * Line,int LineLen);
|
||||
|
||||
void stripTrailingSpace(char * Line);
|
||||
GString getCommandString(char * Com);
|
||||
bool isCommand(char * Line);
|
||||
void checkIsOpen(void);
|
||||
|
||||
protected:
|
||||
bool eof(void);
|
||||
GString peekNextCommand(void);
|
||||
bool nextLineIsCommand(void);
|
||||
GString getNextLine(void);
|
||||
|
||||
void open(char const * fileName);
|
||||
void close(void);
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
ScriptFile(void);
|
||||
~ScriptFile(void);
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Globals
|
||||
------- */
|
||||
|
||||
/* Vars
|
||||
---- */
|
||||
|
||||
/* Data
|
||||
---- */
|
||||
|
||||
/* Functions
|
||||
--------- */
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------- */
|
||||
|
||||
#endif /* __SCRIPT_H__ */
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
||||
|
108
Utils/transtext/transtext.dsp
Normal file
108
Utils/transtext/transtext.dsp
Normal file
|
@ -0,0 +1,108 @@
|
|||
# Microsoft Developer Studio Project File - Name="transtext" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=transtext - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "transtext.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "transtext.mak" CFG="transtext - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "transtext - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "transtext - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""$/TP2psx/utils/transtext", JNXBAAAA"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=xicl6.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "transtext - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\glibdev\glib\include" /I "..\..\glibdev\glib\include\pc" /I "..\tplib" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x809 /d "NDEBUG"
|
||||
# ADD RSC /l 0x809 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=xilink6.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib win32lib.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\glibdev\glib\lib\win32lib\release" /libpath:"..\tplib\release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "transtext - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\glibdev\glib\include" /I "..\..\glibdev\glib\include\pc" /I "..\tplib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
# ADD RSC /l 0x809 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=xilink6.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib win32lib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\glibdev\glib\lib\win32lib\debug" /libpath:"..\tplib\debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "transtext - Win32 Release"
|
||||
# Name "transtext - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\kanjiclass.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\main.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\kanjiclass.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
29
Utils/transtext/transtext.dsw
Normal file
29
Utils/transtext/transtext.dsw
Normal file
|
@ -0,0 +1,29 @@
|
|||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "transtext"=.\transtext.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
60
build/ccopt.mak
Normal file
60
build/ccopt.mak
Normal file
|
@ -0,0 +1,60 @@
|
|||
#----------------------------------------------------------------------------
|
||||
# CCOPT.MAK
|
||||
#
|
||||
# This holds all the command line options for C++
|
||||
# compilation
|
||||
#
|
||||
# Tabbed for 5 9 (Please do not change)
|
||||
#
|
||||
# Created: 3rd February 1999
|
||||
#
|
||||
# Copyright (C) 1997-1998 G R Liddon
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
COMPILER_INI_FILE := $(PSYQ_PATH)/sn.ini
|
||||
|
||||
ASM_OPTS := /l /zd /z /w /q \
|
||||
/o c+ /o w+ /o ws+ \
|
||||
/j $(PSYQ_INC_DIR) \
|
||||
/j $(SOURCE_DIR) \
|
||||
/j ./
|
||||
|
||||
|
||||
|
||||
COMMON_CCFLAGS := -Werror \
|
||||
-D__TERRITORY_$(TERRITORY)__\
|
||||
-D__VERSION_$(VERSION)__\
|
||||
-D__USER_$(USER_NAME)__ \
|
||||
-D__VERSION_STR__=$(VERSION)\
|
||||
-D__TERRITORY_STR__=$(TERRITORY)\
|
||||
-DPSX \
|
||||
-D_LANGUAGE_C_PLUS_PLUS \
|
||||
$(USER_DEF_OPT) \
|
||||
$(GLIB_OPT) \
|
||||
$(FILE_OPT) \
|
||||
$(DEV_OPT) \
|
||||
$(SMALL_OPT) \
|
||||
-Wall \
|
||||
-Wmissing-prototypes\
|
||||
-Wmissing-declarations\
|
||||
-Wno-unused \
|
||||
-Wbad-function-cast \
|
||||
-g \
|
||||
-O2\
|
||||
-fno-builtin\
|
||||
-fomit-frame-pointer\
|
||||
-fno-exceptions \
|
||||
-fno-rtti \
|
||||
-I. \
|
||||
-I$(PSYQ_INC_DIR) \
|
||||
-I$(DDX_INC_DIR)\
|
||||
-I$(MOD_INC_DIR)\
|
||||
-I$(SOURCE_DIR)\
|
||||
-I$(GIN_INC_DIR) \
|
||||
-I$(GAME_DATA_DIR) \
|
||||
-I$(INC_DIR)
|
||||
|
||||
# -fno-inline \
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# end
|
35
build/getuser.mak
Normal file
35
build/getuser.mak
Normal file
|
@ -0,0 +1,35 @@
|
|||
#----------------------------------------------------------------------------
|
||||
# GETUSER.MAK
|
||||
#
|
||||
# Get's the user vars in from their makefile
|
||||
#
|
||||
# Their makefile is at $(USERS_DIR)/<user name>/makefile
|
||||
# The user name is whatever they logged onto
|
||||
# their computer as (in lower case)
|
||||
#
|
||||
# Tabbed for 5 9 (Please do not change)
|
||||
#
|
||||
# Created: 3rd February 1999
|
||||
#
|
||||
# Copyright (C) 1997-1998 G R Liddon
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Now that's all sorted include the users vars
|
||||
# --------------------------------------------
|
||||
|
||||
ifndef USER_NAME
|
||||
|
||||
USER_NAME := $(shell $(LOG_NAME))
|
||||
|
||||
endif
|
||||
|
||||
|
||||
USER_VAR_FILE := $(USERS_DIR)/$(USER_NAME)/makefile
|
||||
|
||||
$(USERS_DIR)/$(USER_NAME)/makefile :
|
||||
@$(ECHO) You Need a user file. See gary liddon
|
||||
|
||||
include $(USER_VAR_FILE)
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# end
|
162
build/globals.mak
Normal file
162
build/globals.mak
Normal file
|
@ -0,0 +1,162 @@
|
|||
#----------------------------------------------------------------------------
|
||||
# globals.mak
|
||||
#
|
||||
# Global defintions for all makefiles
|
||||
# Directory definitions and user preference inclusion
|
||||
#
|
||||
# Tabbed for 5 9 (Please do not change)
|
||||
#
|
||||
# Created: 19th April 1997 by G R Liddon @ Fareham
|
||||
#
|
||||
# Copyright (C) 1997 G R Liddon
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
ifndef __GLOBALS_MAK__
|
||||
__GLOBALS_MAK__ := 1
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Useful Macros
|
||||
# -------------
|
||||
|
||||
NULL :=
|
||||
SPACE := $(NULL) $(NULL)
|
||||
TAB := $(NULL) $(NULL)
|
||||
COMMA := ,
|
||||
LBRACKET := (
|
||||
RBRACKET := )
|
||||
DOLLAR := $$
|
||||
SQUOTE := '
|
||||
DQUOTE := "
|
||||
|
||||
define NEWLINE
|
||||
|
||||
|
||||
endef
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Directory Definitions
|
||||
# ---------------------
|
||||
|
||||
|
||||
# Miscellaneous Dirs
|
||||
# ------------------
|
||||
TOOL_DIR := tools
|
||||
GRAF_DIR := graphics
|
||||
GAME_DATA_DIR := data
|
||||
USERS_DIR := users
|
||||
SOURCE_DIR := source
|
||||
SOUND := sounds
|
||||
|
||||
# Psyq Utilities and libraries
|
||||
# ----------------------------
|
||||
PSYQ_DIR := $(TOOL_DIR)/psyq
|
||||
PSYQ_BIN_DIR := $(PSYQ_DIR)/bin
|
||||
PSYQ_LIB_DIR := $(PSYQ_DIR)/lib
|
||||
PSYQ_INC_DIR := $(PSYQ_DIR)/include
|
||||
|
||||
# DDX Dodgy test kit
|
||||
# ------------------
|
||||
DDX_DIR := $(TOOL_DIR)/climax
|
||||
DDX_BIN_DIR := $(DDX_DIR)/exes
|
||||
DDX_INC_DIR := $(DDX_DIR)/libs
|
||||
DDX_LIB_DIR := $(DDX_DIR)/libs
|
||||
|
||||
# MOD - mod playing lib
|
||||
# ---------------------
|
||||
MOD_DIR := $(TOOL_DIR)/mod
|
||||
MOD_INC_DIR := $(MOD_DIR)/include
|
||||
MOD_LIB_DIR := $(MOD_DIR)/lib
|
||||
|
||||
# VLC - FMV decoder
|
||||
# ---------------------
|
||||
VLC_DIR := $(TOOL_DIR)/vlc
|
||||
VLC_INC_DIR := $(VLC_DIR)/include
|
||||
VLC_LIB_DIR := $(VLC_DIR)/lib
|
||||
|
||||
# GIN tools and includes
|
||||
# ---------------------
|
||||
GIN_TOOL_DIR := $(TOOL_DIR)/gin
|
||||
GIN_BIN_DIR := $(GIN_TOOL_DIR)/bin
|
||||
GIN_INC_DIR := $(GIN_TOOL_DIR)/include
|
||||
|
||||
GIN2MSH := $(GIN_BIN_DIR)/Gin2Msh -q
|
||||
GIN2ACT := $(GIN_BIN_DIR)/Gin2Act -q
|
||||
GIN2ANM := $(GIN_BIN_DIR)/Gin2Anm
|
||||
GIN2LVL := $(GIN_BIN_DIR)/Gin2Kdt -q
|
||||
|
||||
# Cygwin
|
||||
# ------
|
||||
CYG_DIR := $(TOOL_DIR)/cygwin
|
||||
CYG_BIN_DIR := $(CYG_DIR)
|
||||
|
||||
# Perl
|
||||
# ----
|
||||
PERL_DIR := $(TOOL_DIR)/perl
|
||||
PERL_BIN_DIR := $(PERL_DIR)/bin
|
||||
PERL_SCRIPT_DIR := $(PERL_DIR)/pl
|
||||
|
||||
# Cygwin tools
|
||||
# ------------
|
||||
ECHO := $(CYG_BIN_DIR)/echo
|
||||
RMDIR := $(CYG_BIN_DIR)/rmdir
|
||||
MKDIR := $(CYG_BIN_DIR)/mkdir
|
||||
REDIR := glecho
|
||||
TOUCH := touch
|
||||
RM := rm
|
||||
CP := cp
|
||||
SED := sed
|
||||
LS := $(CYG_BIN_DIR)/ls
|
||||
MV := $(CYG_BIN_DIR)/mv
|
||||
DATE := $(CYG_BIN_DIR)/date
|
||||
SED := $(CYG_BIN_DIR)/sed
|
||||
|
||||
LOG_NAME := uname
|
||||
PARKGRAB := parkgrab
|
||||
BANKER := banker
|
||||
BIGLUMP := bl2
|
||||
|
||||
# PSX and misc tools
|
||||
# ------------------
|
||||
LNK := slink
|
||||
PL := perl
|
||||
CC := ccpsx
|
||||
ASM := asmpsx
|
||||
CPE2EXE := cpe2exe
|
||||
CPE2BIN := cpe2bin
|
||||
LZNP := lznp -Q
|
||||
SIZEAPP := sizeapp
|
||||
MAKEDATA := MkData
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Vars that need exporting
|
||||
# ------------------------
|
||||
|
||||
# Path
|
||||
# ----
|
||||
export PATH = $(TOOL_DIR);$(CYG_BIN_DIR);$(PSYQ_BIN_DIR);$(PERL_BIN_DIR)
|
||||
export Path = $(TOOL_DIR);$(CYG_BIN_DIR);$(PSYQ_BIN_DIR);$(PERL_BIN_DIR)
|
||||
|
||||
# PsyQ Vars overidden for those who've installed PSYQ on their machine
|
||||
# --------------------------------------------------------------------
|
||||
export COMPILER_PATH :=
|
||||
export PSYQ_PATH :=
|
||||
export ASSEMBLER_PATH :=
|
||||
export LIBRARY_PATH :=
|
||||
export C_PLUS_INCLUDE_PATH :=
|
||||
export C_INCLUDE_PATH :=
|
||||
|
||||
# These vars are also used by GCC
|
||||
# -------------------------------
|
||||
export GCC_EXEC_PREFIX :=
|
||||
export COMPILER_PATH :=
|
||||
export LIBRARY_PATH :=
|
||||
export C_INCLUDE_PATH :=
|
||||
export CPLUS_INCLUDE_PATH :=
|
||||
export OBJC_INCLUDE_PATH :=
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
endif # __GLOBALS_MAK__
|
||||
#----------------------------------------------------------------------------
|
||||
# end
|
||||
|
88
build/lnk.mak
Normal file
88
build/lnk.mak
Normal file
|
@ -0,0 +1,88 @@
|
|||
#----------------------------------------------------------------------------
|
||||
# LNK.MAK
|
||||
#
|
||||
# This creates the macro that finally makes the linker script file
|
||||
# It also holds any linker options needed
|
||||
#
|
||||
# Tabbed for 5 9 (Please do not change)
|
||||
#
|
||||
# Created: 3rd February 1999
|
||||
#
|
||||
# Copyright (C) 1997-1998 G R Liddon
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
ifndef STACK_SIZE
|
||||
STACK_SIZE := 3000
|
||||
endif
|
||||
|
||||
LNK_FLAGS:= -m -psx -c -v -z -o $(PROG_ORG) -entry __SN_ENTRY_POINT \
|
||||
-cpemunge \
|
||||
-strip \
|
||||
-nsf \
|
||||
$(ALL_ASM_OBJS) \
|
||||
$(PSYQ_LIB_DIR)/libsn.lib \
|
||||
-nsf \
|
||||
-we -wm -wo \
|
||||
-nostrip \
|
||||
stup0 \
|
||||
stup1 \
|
||||
stup2 \
|
||||
VectorNormalS \
|
||||
VectorNormal \
|
||||
VectorNormalSS\
|
||||
cqsrt \
|
||||
-nostrip
|
||||
|
||||
LINKER_FILE_MACRO := \
|
||||
';nostripfile=$(PSYQ_LIB_DIR)/libsn.lib' \
|
||||
'text group ' \
|
||||
'extractors group ' \
|
||||
'extradtors group ' \
|
||||
'data group ' \
|
||||
'sdata group ' \
|
||||
'sbss group bss' \
|
||||
'bss group bss ' \
|
||||
'cached group cache(0x20000000) ' \
|
||||
'' \
|
||||
'' \
|
||||
'memend group bss' \
|
||||
'' \
|
||||
'' \
|
||||
' section .text,text' \
|
||||
' section .cached,cached' \
|
||||
' section .sdata,sdata' \
|
||||
' section .ctors,text' \
|
||||
' section .dtors,text ' \
|
||||
' section .data,data' \
|
||||
' section .rdata,text' \
|
||||
' section .sbss,sbss' \
|
||||
' section .bss,bss' \
|
||||
' section .memend,memend' \
|
||||
' section .last,memend' \
|
||||
'' \
|
||||
'' \
|
||||
'' \
|
||||
'' \
|
||||
'LNK_RamSize equ $(RAM_SIZE)' \
|
||||
'LNK_StackSize equ $(STACK_SIZE)' \
|
||||
'LNK_OrgAddress equ $(PROG_ORG)' \
|
||||
'LNK_FileSys equ $(LNK_FILE_SYS)' \
|
||||
'LNK_DevKit equ $(LNK_DEV_KIT)' \
|
||||
'$(LNK_OVL) ' \
|
||||
'' \
|
||||
'$(TAB)regs$(TAB)pc=__SN_ENTRY_POINT' \
|
||||
'; $(FILE_SYSTEM) Start-Up Objects' \
|
||||
'' \
|
||||
$(foreach FILE,$($(FILE_SYSTEM)_STARTUP_OBJ), '$(TAB)startstats "$(FILE)" ' '$(TAB)include $(PSYQ_LIB_DIR)/$(FILE).obj' '$(TAB)endstats') \
|
||||
'' \
|
||||
'; Main Game object files' \
|
||||
$(foreach FILE,$(CODE_OBJS_TO_MAKE), '$(TAB)startstats "$(subst /,.,$(FILE:$(OBJ_DIR)/%.o=%))" ' '$(TAB)include $(FILE) $(ovl_$(subst /,_,$(FILE:$(OBJ_DIR)/%.o=%)))' '$(TAB)endstats') \
|
||||
$(foreach FILE,$(EXTRA_OBJS), '$(TAB)startstats "$(subst /,.,$(FILE:$(OBJ_DIR)/%.o=%))" ' '$(TAB)include $(FILE) $(ovl_$(subst /,_,$(FILE:$(OBJ_DIR)/%.o=%)))' '$(TAB)endstats') \
|
||||
'' \
|
||||
'; Libs' \
|
||||
$(foreach FILE,$(ALL_LIBS_FULL),'$(TAB)startstats "$(FILE)"' '$(TAB)inclib $(FILE)' '$(TAB)endstats') \
|
||||
''
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# end
|
43
build/outdirs.mak
Normal file
43
build/outdirs.mak
Normal file
|
@ -0,0 +1,43 @@
|
|||
#----------------------------------------------------------------------------
|
||||
# Create all the output directories the game needs
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Macros for ouput dirs
|
||||
# ---------------------
|
||||
OUT_DIR := out/$(TERRITORY)
|
||||
|
||||
OBJ_DIR := $(OUT_DIR)/$(VERSION)/$(FILE_SYSTEM)/objs
|
||||
OBJ_DIRS_TO_MAKE := $(foreach SRC_DIR,$(SRC_DIRS),$(OBJ_DIR)/$(SRC_DIR))
|
||||
VERSION_DIR := $(OUT_DIR)/$(VERSION)/version/$(FILE_SYSTEM)
|
||||
|
||||
DEPS_DIR := $(OUT_DIR)/$(VERSION)/deps/$(FILE_SYSTEM)
|
||||
DEP_DIRS_TO_MAKE := $(foreach SRC_DIR,$(SRC_DIRS),$(DEPS_DIR)/$(SRC_DIR))
|
||||
|
||||
TEMP_DIR := $(OUT_DIR)/$(VERSION)/$(FILE_SYSTEM)/temp
|
||||
TEMP_BUILD_DIR := $(OUT_DIR)/$(VERSION)/build
|
||||
DATA_OUT := $(OUT_DIR)/data
|
||||
INC_DIR := $(OUT_DIR)/include
|
||||
REPORT_DIR := $(OUT_DIR)/report
|
||||
SYSTEM_GEN_DIR := $(SOURCE_DIR)/system/$(VERSION)/$(TERRITORY)/$(FILE_SYSTEM)
|
||||
SYSTEM_GEN_DIR_O := $(OBJ_DIR)/system/$(VERSION)/$(TERRITORY)/$(FILE_SYSTEM)
|
||||
SYSTEM_GEN_DIR_D := $(DEPS_DIR)/system/$(VERSION)/$(TERRITORY)/$(FILE_SYSTEM)
|
||||
|
||||
DIRS_TO_MAKE := $(OBJ_DIR) $(VERSION_DIR) $(TEMP_DIR) $(DEPS_DIR) $(OBJ_DIRS_TO_MAKE) $(DEP_DIRS_TO_MAKE) $(TEMP_BUILD_DIR) $(DATA_OUT) $(INC_DIR) $(REPORT_DIR) $(SYSTEM_GEN_DIR) $(SYSTEM_GEN_DIR_O) $(SYSTEM_GEN_DIR_D)
|
||||
|
||||
# DIRS_TO_MAKE := $(OBJ_DIR) $(VERSION_DIR) $(DEPS_DIR) $(OBJ_DIRS_TO_MAKE) $(TEMP_DIR) $(DEP_DIRS_TO_MAKE) $(TEMP_BUILD_DIR) $(DATA_OUT) $(INC_DIR) $(REPORT_DIR) $(SIZES_DIR) $(SYSTEM_GEN_DIR) $(SYSTEM_GEN_DIR_O) $(SYSTEM_GEN_DIR_D)
|
||||
|
||||
# Stuff needed to make output dirs
|
||||
# --------------------------------
|
||||
.PHONY: dirs
|
||||
|
||||
$(DIRS_TO_MAKE) :
|
||||
@$(MKDIR) -p $(DIRS_TO_MAKE)
|
||||
@$(ECHO) Created directories $(DIRS_TO_MAKE)
|
||||
|
||||
dirs : $(DIRS_TO_MAKE)
|
||||
|
||||
# Some more exports to do after we've decided what the temp dir is
|
||||
# ----------------------------------------------------------------
|
||||
export TEMP := $(TEMP_DIR)
|
||||
export TMPDIR := $(TEMP_DIR)
|
||||
export DEPENDENCIES_OUTPUT := $(TEMP_DIR)/dep.tmp
|
288
build/parse.mak
Normal file
288
build/parse.mak
Normal file
|
@ -0,0 +1,288 @@
|
|||
#----------------------------------------------------------------------------
|
||||
# PARSE.MAK
|
||||
#
|
||||
# Makes sure all the that need defining to build the game have been defined
|
||||
# If not ERR_STR is defined and this cause the makefile to report an error
|
||||
#
|
||||
# Tabbed for 5 9 (Please do not change)
|
||||
#
|
||||
# Created:
|
||||
#
|
||||
# Copyright (C) 1997-1999 G R Liddon
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Make sure the basics are defined first
|
||||
# --------------------------------------
|
||||
ifndef TERRITORY
|
||||
|
||||
ERR_STR := You must define a territory to build for (USA EUR || JAP)
|
||||
|
||||
endif
|
||||
|
||||
ifndef VERSION
|
||||
|
||||
ERR_STR := You must define a version to build
|
||||
|
||||
endif
|
||||
|
||||
|
||||
# Now Parse for the dev kit stuff
|
||||
# ----------------------------------
|
||||
ifdef PSYQ_DEV_IRQ
|
||||
|
||||
PSYQ_DEV_IRQ_OPT := /i$(PSYQ_DEV_IRQ)
|
||||
|
||||
endif
|
||||
|
||||
ifndef DEV_KIT
|
||||
ERR_STR := You must define DEV_KIT to either SONY_ISA or SONY_PCI or CLIMAX or TPWART
|
||||
else
|
||||
DEV_OPT := -DSONY_ISA=0 \
|
||||
-DSONY_PCI=1 \
|
||||
-DCLIMAX=2 \
|
||||
-DTPWART=3 \
|
||||
-D__DEV_KIT__=$(DEV_KIT)
|
||||
|
||||
DK_SONY_ISA := 0
|
||||
DK_SONY_PCI := 1
|
||||
DK_CLIMAX := 2
|
||||
DK_TPWART := 3
|
||||
DK_SONY_H2700 := $(DK_SONY_PCI)
|
||||
|
||||
LNK_DEV_KIT := $(DK_$(DEV_KIT))
|
||||
|
||||
endif
|
||||
|
||||
# Now sort out how the game loads files
|
||||
# -------------------------------------
|
||||
ifndef FILE_SYSTEM
|
||||
ERR_STR := You must define FILE_SYSTEM to either PC or CD
|
||||
else
|
||||
FILE_OPT := -DPC=0 \
|
||||
-DCD=1 \
|
||||
-D__FILE_SYSTEM__=$(FILE_SYSTEM)
|
||||
|
||||
FS_PC := 0
|
||||
FS_CD := 1
|
||||
|
||||
LNK_FILE_SYS := $(FS_$(FILE_SYSTEM))
|
||||
|
||||
endif
|
||||
|
||||
# Make sure we have everything we need for the sony pci dev kit
|
||||
# --------------------------------------------------------------
|
||||
ifeq ($(DEV_KIT),SONY_PCI)
|
||||
|
||||
DEV_KIT_FOUND := 1
|
||||
|
||||
endif
|
||||
|
||||
# Make sure we have everything we need for the climax dev kit
|
||||
# -----------------------------------------------------------
|
||||
ifeq ($(DEV_KIT),CLIMAX)
|
||||
|
||||
ifndef DDX_PORT
|
||||
|
||||
ERR_STR := You must define DDX_PORT for the Climax dev kit i/o addr in your personal makefile
|
||||
|
||||
endif
|
||||
|
||||
DEV_KIT_FOUND := 1
|
||||
|
||||
endif
|
||||
|
||||
|
||||
# Make sure we have everything we need for the climax dev kit
|
||||
# -----------------------------------------------------------
|
||||
ifeq ($(DEV_KIT),TPWART)
|
||||
|
||||
ifndef DDX_PORT
|
||||
|
||||
ERR_STR := You must define DDX_PORT for the Climax dev kit i/o addr in your personal makefile
|
||||
|
||||
endif
|
||||
|
||||
DEV_KIT_FOUND := 1
|
||||
|
||||
endif
|
||||
|
||||
|
||||
# Make sure we have everything we need for the Sony H2000
|
||||
# --------------------------------------------------------------------
|
||||
ifeq ($(DEV_KIT),SONY_ISA)
|
||||
|
||||
ifdef SONY_ISA_IRQ
|
||||
|
||||
SONY_ISA_IRQ_OPT := /i $(SONY_ISA_IRQ)
|
||||
|
||||
endif
|
||||
|
||||
ifndef SONY_ISA_ADDR
|
||||
|
||||
ERR_STR := You must define SONY_ISA_ADDR for the dtl i/o addr in your personal makefile
|
||||
|
||||
endif
|
||||
|
||||
DEV_KIT_FOUND := 1
|
||||
|
||||
endif
|
||||
|
||||
# Make sure we have everything we need for the Sony H2700
|
||||
# -------------------------------------------------------
|
||||
ifeq ($(DEV_KIT),SONY_H2700)
|
||||
|
||||
ifdef SONY_ISA_IRQ
|
||||
|
||||
SONY_ISA_IRQ_OPT := /i $(SONY_ISA_IRQ)
|
||||
|
||||
endif
|
||||
|
||||
ifndef SONY_ISA_ADDR
|
||||
|
||||
ERR_STR := You must define SONY_ISA_ADDR for the dtl i/o addr in your personal makefile
|
||||
|
||||
endif
|
||||
|
||||
DEV_KIT_FOUND := 1
|
||||
|
||||
endif
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Macros for dev BIOS load \ unload for all the dev systems
|
||||
# All take form LOAD_BIOS_$(DEV_KIT)
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# PCI Bios load \ unload
|
||||
# ----------------------
|
||||
define LOAD_BIOS_SONY_PCI
|
||||
h25bios
|
||||
RESETPS 1 /n
|
||||
endef
|
||||
|
||||
define UNLOAD_BIOS_SONY_PCI
|
||||
-mess1
|
||||
h25bios
|
||||
endef
|
||||
|
||||
# H2700 Bios load \ unload
|
||||
# ------------------------
|
||||
define LOAD_BIOS_SONY_H2700
|
||||
-mess1
|
||||
-dexbios /a $(SONY_ISA_ADDR) $(SONY_ISA_IRQ_OPT)
|
||||
RESETPS 1 /n
|
||||
endef
|
||||
|
||||
define UNLOAD_BIOS_SONY_H2700
|
||||
-dexbios
|
||||
-mess1
|
||||
endef
|
||||
|
||||
|
||||
# ISA Bios load \ unload
|
||||
# ----------------------
|
||||
define LOAD_BIOS_SONY_ISA
|
||||
-mess1
|
||||
-dexbios /a $(SONY_ISA_ADDR) $(SONY_ISA_IRQ_OPT)
|
||||
RESETPS 1
|
||||
RUN /w4 $(subst /,\,$(PSYQ_BIN_DIR)\snpatch.cpe) > con
|
||||
DELAY
|
||||
endef
|
||||
|
||||
define UNLOAD_BIOS_SONY_ISA
|
||||
-mess1
|
||||
-dexbios
|
||||
endef
|
||||
|
||||
|
||||
# CLIMAX Bios load \ unload
|
||||
# ------------------------
|
||||
define LOAD_BIOS_CLIMAX
|
||||
-mess1
|
||||
-datbios
|
||||
endef
|
||||
|
||||
define UNLOAD_BIOS_CLIMAX
|
||||
-datbios
|
||||
-mess1
|
||||
endef
|
||||
|
||||
|
||||
# TPWART Bios load \ unload
|
||||
# ------------------------
|
||||
define LOAD_BIOS_TPWART
|
||||
-mess1
|
||||
-psy /4
|
||||
endef
|
||||
|
||||
define UNLOAD_BIOS_TPWART
|
||||
-psy
|
||||
-mess1
|
||||
endef
|
||||
|
||||
# Set the LOAD\UNLOAD_BIOS macros correctly
|
||||
# -----------------------------------------
|
||||
LOAD_BIOS := $(LOAD_BIOS_$(DEV_KIT))
|
||||
UNLOAD_BIOS := $(UNLOAD_BIOS_$(DEV_KIT))
|
||||
|
||||
|
||||
# Check to make sure we found a dev kit we know about
|
||||
# ---------------------------------------------------
|
||||
ifndef ERR_STR
|
||||
|
||||
ifndef DEV_KIT_FOUND
|
||||
ERR_STR := $(DEV_KIT) is not a recognised dev kit
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
# Sort out the compiler we're using
|
||||
# ---------------------------------
|
||||
ifdef USE_EGCS
|
||||
|
||||
COMPILER := egcs
|
||||
|
||||
else
|
||||
|
||||
COMPILER := gnu
|
||||
|
||||
endif
|
||||
|
||||
export PSYQ_PATH := $(PSYQ_BIN_DIR)/$(COMPILER)
|
||||
export SN_PATH := $(PSYQ_BIN_DIR)/$(COMPILER)
|
||||
|
||||
|
||||
# Define what we need for the ram size
|
||||
# ------------------------------------
|
||||
ifdef RAM_SIZE
|
||||
MEG := $(RAM_SIZE)
|
||||
else
|
||||
MEG := 8
|
||||
endif
|
||||
|
||||
MEG_OPT := -D__MEG$(MEG)__
|
||||
|
||||
|
||||
# Bodge Address for 4 meg dev kit
|
||||
# -------------------------------
|
||||
ifeq ($(VERSION),debug)
|
||||
|
||||
GLIB_OPT := -D__GL_DEBUG__
|
||||
|
||||
else
|
||||
|
||||
GLIB_OPT :=
|
||||
|
||||
endif
|
||||
|
||||
|
||||
# Bodge Address for 4 meg dev kit
|
||||
# -------------------------------
|
||||
ifeq ($(RAM_SIZE),4)
|
||||
PROG_ORG = 0x80210000
|
||||
else
|
||||
PROG_ORG = 0x80010000
|
||||
endif
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# end
|
703
data/DataCache.scr
Normal file
703
data/DataCache.scr
Normal file
|
@ -0,0 +1,703 @@
|
|||
translations/swe.dat
|
||||
translations/dut.dat
|
||||
translations/ita.dat
|
||||
translations/ger.dat
|
||||
translations/id.dat
|
||||
translations/eng.dat
|
||||
{ SYSTEM_CACHE 4
|
||||
anims/Generic.Abk
|
||||
anims/Civ.Abk
|
||||
anims/Boss.Abk
|
||||
anims/Missions.Abk
|
||||
sounds/ui/ui.bof
|
||||
}
|
||||
|
||||
ui/UIGfx.Spr
|
||||
sfx/sfx.spr
|
||||
options/options.spr
|
||||
|
||||
sounds/ui/ui.bnk
|
||||
pickups/pickup_gfx.tex
|
||||
sounds/generic/generic.bnk
|
||||
sounds/generic/generic.bof
|
||||
actors/GENGRP.tex
|
||||
|
||||
######################################
|
||||
### Front End ########################
|
||||
######################################
|
||||
{ FRONTEND_CACHE 4
|
||||
#options/gameopt.gfx
|
||||
options/optmod.msh
|
||||
options/optq.msh
|
||||
actors/PRB.act
|
||||
actors/PRG.act
|
||||
actors/PRM.act
|
||||
actors/PRP.act
|
||||
actors/PRR.act
|
||||
actors/PRY.act
|
||||
sounds/gameopts/gameopts.bof
|
||||
}
|
||||
sounds/gameopts/gameopts.bnk
|
||||
|
||||
actors/PRB.act
|
||||
actors/PRB.tex
|
||||
actors/PRG.act
|
||||
actors/PRG.tex
|
||||
actors/PRM.act
|
||||
actors/PRM.tex
|
||||
actors/PRP.act
|
||||
actors/PRP.tex
|
||||
actors/PRR.act
|
||||
actors/PRR.tex
|
||||
actors/PRY.act
|
||||
actors/PRY.tex
|
||||
|
||||
options/gameopt.gfx
|
||||
sounds/pause/pause.bnk
|
||||
sounds/pause/pause.bof
|
||||
|
||||
######################################
|
||||
### LEVEL 1 ##########################
|
||||
######################################
|
||||
music/LEVEL1.VH
|
||||
music/LEVEL1.VB
|
||||
Levels/LEVEL1.tex
|
||||
|
||||
{ LEVEL1_CACHE 4
|
||||
# Generic
|
||||
ui/PAUSEMENU.msh
|
||||
ui/PAUSELIGHTS.msh
|
||||
ui/PAUSELIGHTS2.msh
|
||||
ui/compass.msh
|
||||
ui/moveon.msh
|
||||
sfx/asteroid.msh
|
||||
sfx/card.msh
|
||||
sfx/dagger.msh
|
||||
sfx/icicle.msh
|
||||
sfx/missile.msh
|
||||
sfx/projectile.msh
|
||||
sfx/sonic.msh
|
||||
sfx/telesphere.msh
|
||||
pickups/pu-health.msh
|
||||
pickups/pu-crr.msh
|
||||
pickups/pu-crg.msh
|
||||
pickups/pu-crb.msh
|
||||
pickups/pu-cry.msh
|
||||
pickups/pu-crp.msh
|
||||
pickups/pu-invun.msh
|
||||
pickups/pu-life.msh
|
||||
pickups/pu-mosb.msh
|
||||
pickups/pu-mogo.msh
|
||||
pickups/pu-mosg.msh
|
||||
pickups/pu-mosr.msh
|
||||
pickups/pu-mogp.msh
|
||||
pickups/pu-card.msh
|
||||
pickups/pu-keyt.msh
|
||||
pickups/pu-sell.msh
|
||||
# pickups/pu-sward.msh
|
||||
pickups/pu-aura00.msh
|
||||
pickups/pu-aura10.msh
|
||||
pickups/pu-aura11.msh
|
||||
pickups/pu-aura20.msh
|
||||
pickups/pu-aura30.msh
|
||||
pickups/pu-aura31.msh
|
||||
pickups/pu-aura40.msh
|
||||
pickups/pu-aura00blue.msh
|
||||
|
||||
# Actors
|
||||
actors/CAPTAIN.Act
|
||||
actors/FAIRWEATHER.Act
|
||||
actors/KID.Act
|
||||
actors/MAN.Act
|
||||
actors/M01BLUE.Act
|
||||
actors/M10.Act
|
||||
actors/B03.Act
|
||||
|
||||
# Level Data
|
||||
Levels/LEVEL1.lvl
|
||||
|
||||
# Sound & Music
|
||||
music/LEVEL1.PXM
|
||||
sounds/level1/level1.bof
|
||||
}
|
||||
actors/L01GRP.tex
|
||||
sounds/level1/level1.bnk
|
||||
|
||||
######################################
|
||||
### LEVEL 2 ##########################
|
||||
######################################
|
||||
music/LEVEL2.VH
|
||||
music/LEVEL2.VB
|
||||
Levels/LEVEL2.tex
|
||||
|
||||
{ LEVEL2_CACHE 4
|
||||
# Generic
|
||||
ui/PAUSEMENU.msh
|
||||
ui/PAUSELIGHTS.msh
|
||||
ui/PAUSELIGHTS2.msh
|
||||
ui/compass.msh
|
||||
ui/moveon.msh
|
||||
sfx/asteroid.msh
|
||||
sfx/card.msh
|
||||
sfx/dagger.msh
|
||||
sfx/icicle.msh
|
||||
sfx/missile.msh
|
||||
sfx/projectile.msh
|
||||
sfx/sonic.msh
|
||||
sfx/telesphere.msh
|
||||
pickups/pu-health.msh
|
||||
pickups/pu-crr.msh
|
||||
pickups/pu-crg.msh
|
||||
pickups/pu-crb.msh
|
||||
pickups/pu-cry.msh
|
||||
pickups/pu-crp.msh
|
||||
pickups/pu-invun.msh
|
||||
pickups/pu-life.msh
|
||||
pickups/pu-mosb.msh
|
||||
pickups/pu-mogo.msh
|
||||
pickups/pu-mosg.msh
|
||||
pickups/pu-mosr.msh
|
||||
pickups/pu-mogp.msh
|
||||
pickups/pu-card.msh
|
||||
pickups/pu-keyt.msh
|
||||
pickups/pu-sell.msh
|
||||
pickups/pu-sward.msh
|
||||
pickups/pu-aura00.msh
|
||||
pickups/pu-aura10.msh
|
||||
pickups/pu-aura11.msh
|
||||
pickups/pu-aura20.msh
|
||||
pickups/pu-aura30.msh
|
||||
pickups/pu-aura31.msh
|
||||
pickups/pu-aura40.msh
|
||||
pickups/pu-aura00blue.msh
|
||||
|
||||
# Level Data
|
||||
Levels/LEVEL2.lvl
|
||||
|
||||
# Actors
|
||||
actors/CAPTAIN.Act
|
||||
actors/FAIRWEATHER.Act
|
||||
actors/KID.Act
|
||||
actors/BOY.Act
|
||||
queencocoon/queencocoon.msh
|
||||
actors/M01ORANGE.Act
|
||||
actors/M07.Act
|
||||
actors/B04.Act
|
||||
|
||||
# Sound & Music
|
||||
music/LEVEL2.PXM
|
||||
sounds/level2/level2.bof
|
||||
}
|
||||
actors/L02GRP.tex
|
||||
sounds/level2/level2.bnk
|
||||
|
||||
######################################
|
||||
### LEVEL 3 ##########################
|
||||
######################################
|
||||
music/LEVEL3.VH
|
||||
music/LEVEL3.VB
|
||||
Levels/LEVEL3.tex
|
||||
|
||||
{ LEVEL3_CACHE 4
|
||||
# Generic
|
||||
ui/PAUSEMENU.msh
|
||||
ui/PAUSELIGHTS.msh
|
||||
ui/PAUSELIGHTS2.msh
|
||||
ui/compass.msh
|
||||
ui/moveon.msh
|
||||
sfx/asteroid.msh
|
||||
sfx/card.msh
|
||||
sfx/dagger.msh
|
||||
sfx/icicle.msh
|
||||
sfx/missile.msh
|
||||
sfx/projectile.msh
|
||||
sfx/sonic.msh
|
||||
sfx/telesphere.msh
|
||||
pickups/pu-health.msh
|
||||
pickups/pu-crr.msh
|
||||
pickups/pu-crg.msh
|
||||
pickups/pu-crb.msh
|
||||
pickups/pu-cry.msh
|
||||
pickups/pu-crp.msh
|
||||
pickups/pu-invun.msh
|
||||
pickups/pu-life.msh
|
||||
pickups/pu-mosb.msh
|
||||
pickups/pu-mogo.msh
|
||||
pickups/pu-mosg.msh
|
||||
pickups/pu-mosr.msh
|
||||
pickups/pu-mogp.msh
|
||||
pickups/pu-card.msh
|
||||
pickups/pu-keyt.msh
|
||||
pickups/pu-sell.msh
|
||||
# pickups/pu-sward.msh
|
||||
pickups/pu-aura00.msh
|
||||
pickups/pu-aura10.msh
|
||||
pickups/pu-aura11.msh
|
||||
pickups/pu-aura20.msh
|
||||
pickups/pu-aura30.msh
|
||||
pickups/pu-aura31.msh
|
||||
pickups/pu-aura40.msh
|
||||
pickups/pu-aura00blue.msh
|
||||
|
||||
#Level Data
|
||||
Levels/LEVEL3.lvl
|
||||
levels/section1.msh
|
||||
levels/section2.msh
|
||||
levels/section3.msh
|
||||
levels/section4.msh
|
||||
levels/section5.msh
|
||||
levels/section6.msh
|
||||
|
||||
# Actors
|
||||
actors/CAPTAIN.Act
|
||||
actors/FAIRWEATHER.Act
|
||||
actors/KID.Act
|
||||
actors/M01GREEN.Act
|
||||
actors/B05.Act
|
||||
|
||||
#Sound & Music
|
||||
music/LEVEL3.PXM
|
||||
sounds/level3/level3.bof
|
||||
}
|
||||
actors/L03GRP.tex
|
||||
sounds/level3/level3.bnk
|
||||
|
||||
######################################
|
||||
### LEVEL 4 ##########################
|
||||
######################################
|
||||
music/LEVEL4.VH
|
||||
music/LEVEL4.VB
|
||||
Levels/LEVEL4.tex
|
||||
|
||||
{ LEVEL4_CACHE 4
|
||||
# Generic
|
||||
ui/PAUSEMENU.msh
|
||||
ui/PAUSELIGHTS.msh
|
||||
ui/PAUSELIGHTS2.msh
|
||||
ui/compass.msh
|
||||
ui/moveon.msh
|
||||
sfx/asteroid.msh
|
||||
sfx/card.msh
|
||||
sfx/dagger.msh
|
||||
sfx/icicle.msh
|
||||
sfx/missile.msh
|
||||
sfx/projectile.msh
|
||||
sfx/sonic.msh
|
||||
sfx/telesphere.msh
|
||||
pickups/pu-health.msh
|
||||
pickups/pu-crr.msh
|
||||
pickups/pu-crg.msh
|
||||
pickups/pu-crb.msh
|
||||
pickups/pu-cry.msh
|
||||
pickups/pu-crp.msh
|
||||
pickups/pu-invun.msh
|
||||
pickups/pu-life.msh
|
||||
pickups/pu-mosb.msh
|
||||
pickups/pu-mogo.msh
|
||||
pickups/pu-mosg.msh
|
||||
pickups/pu-mosr.msh
|
||||
pickups/pu-mogp.msh
|
||||
pickups/pu-card.msh
|
||||
pickups/pu-keyt.msh
|
||||
pickups/pu-sell.msh
|
||||
# pickups/pu-sward.msh
|
||||
pickups/pu-aura00.msh
|
||||
pickups/pu-aura10.msh
|
||||
pickups/pu-aura11.msh
|
||||
pickups/pu-aura20.msh
|
||||
pickups/pu-aura30.msh
|
||||
pickups/pu-aura31.msh
|
||||
pickups/pu-aura40.msh
|
||||
pickups/pu-aura00blue.msh
|
||||
|
||||
# Level Data
|
||||
Levels/LEVEL4.lvl
|
||||
|
||||
# Actors
|
||||
actors/CAPTAIN.Act
|
||||
actors/FAIRWEATHER.Act
|
||||
actors/MAN.Act
|
||||
actors/BOY.Act
|
||||
actors/KID.Act
|
||||
actors/M01.Act
|
||||
actors/M02.Act
|
||||
actors/M03.Act
|
||||
actors/B02.Act
|
||||
|
||||
# Sound & Music
|
||||
music/LEVEL4.PXM
|
||||
sounds/level4/level4.bof
|
||||
}
|
||||
actors/L04GRP.tex
|
||||
sounds/level4/level4.bnk
|
||||
|
||||
######################################
|
||||
### LEVEL 5 ##########################
|
||||
######################################
|
||||
music/LEVEL5.VH
|
||||
music/LEVEL5.VB
|
||||
Levels/LEVEL5.tex
|
||||
|
||||
{ LEVEL5_CACHE 4
|
||||
# Generic
|
||||
ui/PAUSEMENU.msh
|
||||
ui/PAUSELIGHTS.msh
|
||||
ui/PAUSELIGHTS2.msh
|
||||
ui/compass.msh
|
||||
ui/moveon.msh
|
||||
sfx/asteroid.msh
|
||||
sfx/card.msh
|
||||
sfx/dagger.msh
|
||||
sfx/icicle.msh
|
||||
sfx/missile.msh
|
||||
sfx/projectile.msh
|
||||
sfx/sonic.msh
|
||||
sfx/telesphere.msh
|
||||
pickups/pu-health.msh
|
||||
pickups/pu-crr.msh
|
||||
pickups/pu-crg.msh
|
||||
pickups/pu-crb.msh
|
||||
pickups/pu-cry.msh
|
||||
pickups/pu-crp.msh
|
||||
pickups/pu-invun.msh
|
||||
pickups/pu-life.msh
|
||||
pickups/pu-mosb.msh
|
||||
pickups/pu-mogo.msh
|
||||
pickups/pu-mosg.msh
|
||||
pickups/pu-mosr.msh
|
||||
pickups/pu-mogp.msh
|
||||
pickups/pu-card.msh
|
||||
pickups/pu-keyt.msh
|
||||
pickups/pu-sell.msh
|
||||
# pickups/pu-sward.msh
|
||||
pickups/pu-aura00.msh
|
||||
pickups/pu-aura10.msh
|
||||
pickups/pu-aura11.msh
|
||||
pickups/pu-aura20.msh
|
||||
pickups/pu-aura30.msh
|
||||
pickups/pu-aura31.msh
|
||||
pickups/pu-aura40.msh
|
||||
pickups/pu-aura00blue.msh
|
||||
|
||||
# Level Data
|
||||
Levels/LEVEL5.lvl
|
||||
|
||||
# Actors
|
||||
actors/CAPTAIN.Act
|
||||
actors/FAIRWEATHER.Act
|
||||
actors/KID.Act
|
||||
actors/M01PURPLE.Act
|
||||
actors/M08.Act
|
||||
actors/B06.Act
|
||||
|
||||
# Sound & Music
|
||||
music/LEVEL5.PXM
|
||||
sounds/level5/level5.bof
|
||||
}
|
||||
actors/L05GRP.tex
|
||||
sounds/level5/level5.bnk
|
||||
|
||||
######################################
|
||||
### LEVEL 6 ##########################
|
||||
######################################
|
||||
music/LEVEL6.VH
|
||||
music/LEVEL6.VB
|
||||
Levels/LEVEL6.tex
|
||||
|
||||
{ LEVEL6_CACHE 4
|
||||
# Generic
|
||||
ui/PAUSEMENU.msh
|
||||
ui/PAUSELIGHTS.msh
|
||||
ui/PAUSELIGHTS2.msh
|
||||
ui/compass.msh
|
||||
ui/moveon.msh
|
||||
sfx/asteroid.msh
|
||||
sfx/card.msh
|
||||
sfx/dagger.msh
|
||||
sfx/icicle.msh
|
||||
sfx/missile.msh
|
||||
sfx/projectile.msh
|
||||
sfx/sonic.msh
|
||||
sfx/telesphere.msh
|
||||
pickups/pu-health.msh
|
||||
pickups/pu-crr.msh
|
||||
pickups/pu-crg.msh
|
||||
pickups/pu-crb.msh
|
||||
pickups/pu-cry.msh
|
||||
pickups/pu-crp.msh
|
||||
pickups/pu-invun.msh
|
||||
pickups/pu-life.msh
|
||||
pickups/pu-mosb.msh
|
||||
pickups/pu-mogo.msh
|
||||
pickups/pu-mosg.msh
|
||||
pickups/pu-mosr.msh
|
||||
pickups/pu-mogp.msh
|
||||
pickups/pu-card.msh
|
||||
pickups/pu-keyt.msh
|
||||
pickups/pu-sell.msh
|
||||
# pickups/pu-sward.msh
|
||||
pickups/pu-aura00.msh
|
||||
pickups/pu-aura10.msh
|
||||
pickups/pu-aura11.msh
|
||||
pickups/pu-aura20.msh
|
||||
pickups/pu-aura30.msh
|
||||
pickups/pu-aura31.msh
|
||||
pickups/pu-aura40.msh
|
||||
pickups/pu-aura00blue.msh
|
||||
|
||||
# Level Data
|
||||
Levels/LEVEL6.lvl
|
||||
|
||||
# Actors
|
||||
actors/CAPTAIN.Act
|
||||
actors/FAIRWEATHER.Act
|
||||
actors/SCIENTIST.Act
|
||||
actors/KID.Act
|
||||
queencocoon/queencocoon.msh
|
||||
actors/M01PINK.Act
|
||||
actors/M06.Act
|
||||
actors/M09.Act
|
||||
|
||||
# Sound & Music
|
||||
music/LEVEL6.PXM
|
||||
sounds/level6/level6.bof
|
||||
}
|
||||
actors/L06GRP.tex
|
||||
sounds/level6/level6.bnk
|
||||
|
||||
######################################
|
||||
### LEVEL 7 ##########################
|
||||
######################################
|
||||
music/LEVEL7.VH
|
||||
music/LEVEL7.VB
|
||||
Levels/LEVEL7.tex
|
||||
|
||||
{ LEVEL7_CACHE 4
|
||||
# Generic
|
||||
ui/PAUSEMENU.msh
|
||||
ui/PAUSELIGHTS.msh
|
||||
ui/PAUSELIGHTS2.msh
|
||||
ui/compass.msh
|
||||
ui/moveon.msh
|
||||
sfx/asteroid.msh
|
||||
sfx/card.msh
|
||||
sfx/dagger.msh
|
||||
sfx/icicle.msh
|
||||
sfx/missile.msh
|
||||
sfx/projectile.msh
|
||||
sfx/sonic.msh
|
||||
sfx/telesphere.msh
|
||||
pickups/pu-health.msh
|
||||
pickups/pu-crr.msh
|
||||
pickups/pu-crg.msh
|
||||
pickups/pu-crb.msh
|
||||
pickups/pu-cry.msh
|
||||
pickups/pu-crp.msh
|
||||
pickups/pu-invun.msh
|
||||
pickups/pu-life.msh
|
||||
pickups/pu-mosb.msh
|
||||
pickups/pu-mogo.msh
|
||||
pickups/pu-mosg.msh
|
||||
pickups/pu-mosr.msh
|
||||
pickups/pu-mogp.msh
|
||||
pickups/pu-card.msh
|
||||
pickups/pu-keyt.msh
|
||||
pickups/pu-sell.msh
|
||||
# pickups/pu-sward.msh
|
||||
pickups/pu-aura00.msh
|
||||
pickups/pu-aura10.msh
|
||||
pickups/pu-aura11.msh
|
||||
pickups/pu-aura20.msh
|
||||
pickups/pu-aura30.msh
|
||||
pickups/pu-aura31.msh
|
||||
pickups/pu-aura40.msh
|
||||
pickups/pu-aura00blue.msh
|
||||
|
||||
# Level Data
|
||||
Levels/LEVEL7.lvl
|
||||
|
||||
# Actors
|
||||
actors/CAPTAIN.Act
|
||||
actors/FAIRWEATHER.Act
|
||||
actors/TITANIUM.Act
|
||||
# actors/kid.Act
|
||||
queencocoon/queencocoon.msh
|
||||
actors/M01YELLOW.Act
|
||||
# actors/B01.Act
|
||||
actors/B02.Act
|
||||
actors/B03.Act
|
||||
actors/B04.Act
|
||||
actors/B05.Act
|
||||
actors/B06.Act
|
||||
|
||||
# Sound & Music
|
||||
music/LEVEL7.PXM
|
||||
sounds/level7/level7.bof
|
||||
}
|
||||
actors/L07GRP.tex
|
||||
sounds/level7/level7.bnk
|
||||
|
||||
######################################
|
||||
### LEVEL 8 ##########################
|
||||
######################################
|
||||
music/LEVEL8.VH
|
||||
music/LEVEL8.VB
|
||||
Levels/LEVEL8.tex
|
||||
|
||||
{ LEVEL8_CACHE 4
|
||||
# Generic
|
||||
ui/PAUSEMENU.msh
|
||||
ui/PAUSELIGHTS.msh
|
||||
ui/PAUSELIGHTS2.msh
|
||||
ui/compass.msh
|
||||
ui/moveon.msh
|
||||
sfx/asteroid.msh
|
||||
sfx/card.msh
|
||||
sfx/dagger.msh
|
||||
sfx/icicle.msh
|
||||
sfx/missile.msh
|
||||
sfx/projectile.msh
|
||||
sfx/sonic.msh
|
||||
sfx/telesphere.msh
|
||||
pickups/pu-health.msh
|
||||
pickups/pu-crr.msh
|
||||
pickups/pu-crg.msh
|
||||
pickups/pu-crb.msh
|
||||
pickups/pu-cry.msh
|
||||
pickups/pu-crp.msh
|
||||
pickups/pu-invun.msh
|
||||
pickups/pu-life.msh
|
||||
pickups/pu-mosb.msh
|
||||
pickups/pu-mogo.msh
|
||||
pickups/pu-mosg.msh
|
||||
pickups/pu-mosr.msh
|
||||
pickups/pu-mogp.msh
|
||||
pickups/pu-card.msh
|
||||
pickups/pu-keyt.msh
|
||||
pickups/pu-sell.msh
|
||||
# pickups/pu-sward.msh
|
||||
pickups/pu-aura00.msh
|
||||
pickups/pu-aura10.msh
|
||||
pickups/pu-aura11.msh
|
||||
pickups/pu-aura20.msh
|
||||
pickups/pu-aura30.msh
|
||||
pickups/pu-aura31.msh
|
||||
pickups/pu-aura40.msh
|
||||
pickups/pu-aura00blue.msh
|
||||
|
||||
# Level Data
|
||||
Levels/LEVEL8.lvl
|
||||
anims/Zord.Abk
|
||||
|
||||
# Actors
|
||||
actors/CAPTAIN.Act
|
||||
actors/FAIRWEATHER.Act
|
||||
actors/KID.Act
|
||||
queencocoon/queencocoon.msh
|
||||
actors/B01.Act
|
||||
actors/B02.Act
|
||||
actors/B04.Act
|
||||
actors/B06.Act
|
||||
|
||||
actors/OMZORD.act
|
||||
actors/STRZORD.act
|
||||
|
||||
# Sound & Music
|
||||
music/LEVEL8.PXM
|
||||
sounds/level8/level8.bof
|
||||
}
|
||||
actors/OMZORD.tex
|
||||
actors/STRZORD.tex
|
||||
sounds/level8/level8.bnk
|
||||
|
||||
######################################
|
||||
### BACKEND ##########################
|
||||
######################################
|
||||
{ BACKEND_CACHE 4
|
||||
ui/hiscore.msh
|
||||
}
|
||||
|
||||
######################################
|
||||
### SCREENS ##########################
|
||||
######################################
|
||||
screens/prlogo.gfx
|
||||
screens/thqlogo.gfx
|
||||
screens/foxkids.gfx
|
||||
screens/credits.gfx
|
||||
screens/loading.gfx
|
||||
|
||||
backend/gover1.gfx
|
||||
backend/gover2.gfx
|
||||
backend/goverc.gfx
|
||||
|
||||
loading/PinkRang.gfx
|
||||
loading/GreenRan.gfx
|
||||
loading/BlueRang.gfx
|
||||
loading/RedRange.gfx
|
||||
loading/TitRange.gfx
|
||||
loading/YellowRa.gfx
|
||||
loading/bots.gfx
|
||||
loading/2PinkRan.gfx
|
||||
loading/2GreenRa.gfx
|
||||
loading/2BlueRan.gfx
|
||||
loading/2RedRang.gfx
|
||||
loading/2TitRang.gfx
|
||||
loading/2YellowR.gfx
|
||||
|
||||
gallery/comic/RedColor.gfx
|
||||
gallery/comic/BlueColo.gfx
|
||||
gallery/comic/GreenCol.gfx
|
||||
gallery/comic/YellowCo.gfx
|
||||
gallery/comic/PinkColo.gfx
|
||||
gallery/comic/Titanium.gfx
|
||||
gallery/comic/VypraCol.gfx
|
||||
gallery/comic/QueenFac.gfx
|
||||
gallery/maps/DamLv1st.gfx
|
||||
gallery/maps/DamLv2nd.gfx
|
||||
gallery/maps/DamLv3rd.gfx
|
||||
gallery/maps/CityS1st.gfx
|
||||
gallery/maps/CityS2nd.gfx
|
||||
gallery/maps/CityS3rd.gfx
|
||||
gallery/maps/Docks1st.gfx
|
||||
gallery/maps/Docks2nd.gfx
|
||||
gallery/models/Abominus.gfx
|
||||
gallery/models/Stingwin.gfx
|
||||
gallery/models/Cpfireor.gfx
|
||||
gallery/models/CpofLoki.gfx
|
||||
gallery/models/Salamand.gfx
|
||||
gallery/models/Shockatr.gfx
|
||||
gallery/models/smoggers.gfx
|
||||
gallery/models/Bansheer.gfx
|
||||
gallery/tvshow/abominus.gfx
|
||||
gallery/tvshow/firejump.gfx
|
||||
gallery/tvshow/fireor.gfx
|
||||
gallery/tvshow/jinxer.gfx
|
||||
gallery/tvshow/oldired.gfx
|
||||
gallery/tvshow/omegmega.gfx
|
||||
gallery/tvshow/poster03.gfx
|
||||
gallery/tvshow/queen.gfx
|
||||
gallery/tvshow/shockact.gfx
|
||||
gallery/tvshow/smogger.gfx
|
||||
gallery/tvshow/striknin.gfx
|
||||
gallery/tvshow/tranmega.gfx
|
||||
|
||||
options/goload.gfx
|
||||
|
||||
######################################
|
||||
### To Be Assigned ###################
|
||||
######################################
|
||||
|
||||
music/LVLCOMP.PXM
|
||||
music/LVLCOMP.VH
|
||||
music/LVLCOMP.VB
|
||||
music/GAMECOMP.PXM
|
||||
music/GAMECOMP.VH
|
||||
music/GAMECOMP.VB
|
||||
music/GAMEOVER.PXM
|
||||
music/GAMEOVER.VH
|
||||
music/GAMEOVER.VB
|
||||
music/GALLERY.PXM
|
||||
music/GALLERY.VH
|
||||
music/GALLERY.VB
|
||||
|
||||
|
9
data/translations/dut.dat
Normal file
9
data/translations/dut.dat
Normal file
|
@ -0,0 +1,9 @@
|
|||
;----------------------------------------
|
||||
; Please
|
||||
; DO NOT edit this document with word
|
||||
; DO NOT add trailing spaces and tabs
|
||||
; DO NOT Omit text after identifier
|
||||
; DO NOT add spaces to identifier
|
||||
; DO NOT add duplicate identifiers
|
||||
;----------------------------------------
|
||||
|
9
data/translations/ger.dat
Normal file
9
data/translations/ger.dat
Normal file
|
@ -0,0 +1,9 @@
|
|||
;----------------------------------------
|
||||
; Please
|
||||
; DO NOT edit this document with word
|
||||
; DO NOT add trailing spaces and tabs
|
||||
; DO NOT Omit text after identifier
|
||||
; DO NOT add spaces to identifier
|
||||
; DO NOT add duplicate identifiers
|
||||
;----------------------------------------
|
||||
|
9
data/translations/ita.dat
Normal file
9
data/translations/ita.dat
Normal file
|
@ -0,0 +1,9 @@
|
|||
;----------------------------------------
|
||||
; Please
|
||||
; DO NOT edit this document with word
|
||||
; DO NOT add trailing spaces and tabs
|
||||
; DO NOT Omit text after identifier
|
||||
; DO NOT add spaces to identifier
|
||||
; DO NOT add duplicate identifiers
|
||||
;----------------------------------------
|
||||
|
9
data/translations/swe.dat
Normal file
9
data/translations/swe.dat
Normal file
|
@ -0,0 +1,9 @@
|
|||
;----------------------------------------
|
||||
; Please
|
||||
; DO NOT edit this document with word
|
||||
; DO NOT add trailing spaces and tabs
|
||||
; DO NOT Omit text after identifier
|
||||
; DO NOT add spaces to identifier
|
||||
; DO NOT add duplicate identifiers
|
||||
;----------------------------------------
|
||||
|
1046
data/translations/text.dat
Normal file
1046
data/translations/text.dat
Normal file
File diff suppressed because it is too large
Load diff
BIN
tools/Banker.exe
Normal file
BIN
tools/Banker.exe
Normal file
Binary file not shown.
BIN
tools/MkData.exe
Normal file
BIN
tools/MkData.exe
Normal file
Binary file not shown.
BIN
tools/MkSpeech.exe
Normal file
BIN
tools/MkSpeech.exe
Normal file
Binary file not shown.
505
tools/Perl/bin/GET
Normal file
505
tools/Perl/bin/GET
Normal file
|
@ -0,0 +1,505 @@
|
|||
#!perl -w
|
||||
|
||||
# $Id: lwp-request.PL,v 1.33 1998/08/04 09:18:11 aas Exp $
|
||||
#
|
||||
# Simple user agent using LWP library.
|
||||
|
||||
=head1 NAME
|
||||
|
||||
lwp-request, GET, HEAD, POST - Simple WWW user agent
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
lwp-request [-aeEdvhx] [-m method] [-b <base URL>] [-t <timeout>]
|
||||
[-i <if-modified-since>] [-c <content-type>] [-C <credentials>]
|
||||
[-p <proxy-url>] [-o <format>] <url>...
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This program can be used to send requests to WWW servers and your
|
||||
local file system. The request content for POST, PUT and CHECKIN
|
||||
methods is read from stdin. The content of the response is printed on
|
||||
stdout. Error messages are printed on stderr. The program returns a
|
||||
status value indicating the number of URLs that failed.
|
||||
|
||||
The options are:
|
||||
|
||||
=over 4
|
||||
|
||||
=item -m <method>
|
||||
|
||||
Set which method to use for the request. If this option is not used,
|
||||
then the method is derived from the name of the program.
|
||||
|
||||
=item -f
|
||||
|
||||
Force request through, even if the program believes that the method is
|
||||
illegal. The server will probably reject the request.
|
||||
|
||||
=item -b <url>
|
||||
|
||||
This URL will be used as the base URL for the URLs that the method is
|
||||
applied to. The base URL only takes effect for relative URLs. If you
|
||||
do not provide this option and the URLs are relative, then they will
|
||||
be treated as files in the local file system.
|
||||
|
||||
=item -t <timeout>
|
||||
|
||||
Set the timeout value for the requests. The timeout is the amount of
|
||||
time that the program will wait for a response from the remote server
|
||||
before it fails. The default unit for the timeout value is seconds.
|
||||
You might append "m" or "h" to the timeout value to make it minutes or
|
||||
hours, respectively. The default timeout is '3m', i.e. 3 minutes.
|
||||
|
||||
=item -i <time>
|
||||
|
||||
Set the If-Modified-Since header in the request. If I<time> it the
|
||||
name of a file, use the modification timestamp for this file. If
|
||||
I<time> is not a file, it is parsed as a literal date. Take a look at
|
||||
L<HTTP::Date> for recogniced formats.
|
||||
|
||||
=item -c <content-type>
|
||||
|
||||
Set the Content-Type for the request. This option is only allowed for
|
||||
requests that take a content, i.e. POST, PUT and CHECKIN. You can
|
||||
force methods to take content by using the C<-f> option together with
|
||||
C<-c>. The default Content-Type for POST is
|
||||
C<application/x-www-form-urlencoded>. The default Content-type for
|
||||
the others is C<text/plain>.
|
||||
|
||||
=item -p <proxy-url>
|
||||
|
||||
Set the proxy to be used for the requests. The program also loads
|
||||
proxy settings from the environment. You can disable this with the
|
||||
C<-P> option.
|
||||
|
||||
=item -C <username>:<password>
|
||||
|
||||
Provide credentials for documents that are protected by Basic
|
||||
Authentication. If the document is protected and you did not specify
|
||||
the username and password with this option, then you will be prompted
|
||||
to provide these values.
|
||||
|
||||
=back
|
||||
|
||||
The following options controls what is displayed by the program:
|
||||
|
||||
=over 4
|
||||
|
||||
=item -u
|
||||
|
||||
Print request method and absolute URL as requests are made.
|
||||
|
||||
=item -U
|
||||
|
||||
Print request headers in addition to request method and absolute URL.
|
||||
|
||||
=item -s
|
||||
|
||||
Print response status code. This option is always on for HEAD requests.
|
||||
|
||||
=item -S
|
||||
|
||||
Print response status chain. This shows redirect and autorization
|
||||
requests that are handled by the library.
|
||||
|
||||
=item -e
|
||||
|
||||
Print response headers. This option is always on for HEAD requests.
|
||||
|
||||
=item -d
|
||||
|
||||
Do B<not> print the content of the response.
|
||||
|
||||
=item -o <format>
|
||||
|
||||
Process HTML content in various ways before printing it. If the
|
||||
content type of the response is not HTML, then this option has no
|
||||
effect. The legal format values are; I<text>, I<ps>, I<links>,
|
||||
I<html> and I<dump>.
|
||||
|
||||
If you specify the I<text> format then the HTML will be formatted as
|
||||
plain latin1 text. If you specify the I<ps> format then it will be
|
||||
formatted as Postscript.
|
||||
|
||||
The I<links> format will output all links found in the HTML document.
|
||||
Relative links will be expanded to absolute ones.
|
||||
|
||||
The I<html> format will reformat the HTML code and the I<dump> format
|
||||
will just dump the HTML syntax tree.
|
||||
|
||||
=item -v
|
||||
|
||||
Print the version number of the program and quit.
|
||||
|
||||
=item -h
|
||||
|
||||
Print usage message and quit.
|
||||
|
||||
=item -x
|
||||
|
||||
Extra debugging output.
|
||||
|
||||
=item -a
|
||||
|
||||
Set text(ascii) mode for content input and output. If this option is not
|
||||
used, content input and output is done in binary mode.
|
||||
|
||||
=back
|
||||
|
||||
Because this program is implemented using the LWP library, it will
|
||||
only support the protocols that LWP supports.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<lwp-mirror>, L<LWP>
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright 1995-1997 Gisle Aas.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the same terms as Perl itself.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Gisle Aas <aas@sn.no>
|
||||
|
||||
=cut
|
||||
|
||||
$progname = $0;
|
||||
$progname =~ s,.*/,,; # use basename only
|
||||
$progname =~ s/\.\w*$//; # strip extension, if any
|
||||
|
||||
$VERSION = sprintf("%d.%02d", q$Revision: 1.33 $ =~ /(\d+)\.(\d+)/);
|
||||
|
||||
|
||||
require LWP;
|
||||
require LWP::Debug;
|
||||
require URI::URL;
|
||||
|
||||
use URI::Heuristic qw(uf_url);
|
||||
|
||||
use HTTP::Status qw(status_message);
|
||||
use HTTP::Date qw(time2str str2time);
|
||||
|
||||
|
||||
# This table lists the methods that are allowed. It should really be
|
||||
# a superset for all methods supported for every scheme that may be
|
||||
# supported by the library. Currently it might be a bit too HTTP
|
||||
# specific. You might use the -f option to force a method through.
|
||||
#
|
||||
# "" = No content in request, "C" = Needs content in request
|
||||
#
|
||||
%allowed_methods = (
|
||||
GET => "",
|
||||
HEAD => "",
|
||||
POST => "C",
|
||||
PUT => "C",
|
||||
DELETE => "",
|
||||
TRACE => "",
|
||||
OPTIONS => "",
|
||||
);
|
||||
|
||||
|
||||
# We make our own specialization of LWP::UserAgent that asks for
|
||||
# user/password if document is protected.
|
||||
{
|
||||
package RequestAgent;
|
||||
@ISA = qw(LWP::UserAgent);
|
||||
|
||||
sub new
|
||||
{
|
||||
my $self = LWP::UserAgent::new(@_);
|
||||
$self->agent("lwp-request/$main::VERSION");
|
||||
$self;
|
||||
}
|
||||
|
||||
sub get_basic_credentials
|
||||
{
|
||||
my($self, $realm, $uri) = @_;
|
||||
if ($main::opt_C) {
|
||||
return split(':', $main::opt_C, 2);
|
||||
} elsif (-t) {
|
||||
my $netloc = $uri->netloc;
|
||||
print "Enter username for $realm at $netloc: ";
|
||||
my $user = <STDIN>;
|
||||
chomp($user);
|
||||
return (undef, undef) unless length $user;
|
||||
print "Password: ";
|
||||
system("stty -echo");
|
||||
my $password = <STDIN>;
|
||||
system("stty echo");
|
||||
print "\n"; # because we disabled echo
|
||||
chomp($password);
|
||||
return ($user, $password);
|
||||
} else {
|
||||
return (undef, undef)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$method = uc(lc($progname) eq "lwp-request" ? "GET" : $progname);
|
||||
|
||||
# Parse command line
|
||||
use Getopt::Std;
|
||||
|
||||
$opt_a = undef; # content i/o in text(ascii) mode
|
||||
$opt_m = undef; # set method
|
||||
$opt_f = undef; # make request even if method is not in %allowed_methods
|
||||
$opt_b = undef; # base url
|
||||
$opt_t = undef; # timeout
|
||||
$opt_i = undef; # if-modified-since
|
||||
$opt_c = undef; # content type for POST
|
||||
$opt_C = undef; # credidentials for basic authorization
|
||||
|
||||
$opt_u = undef; # display method, URL and headers of request
|
||||
$opt_U = undef; # display request headers also
|
||||
$opt_s = undef; # display status code
|
||||
$opt_S = undef; # display whole chain of status codes
|
||||
$opt_e = undef; # display response headers (default for HEAD)
|
||||
$opt_d = undef; # don't display content
|
||||
|
||||
$opt_h = undef; # print usage
|
||||
$opt_v = undef; # print version
|
||||
|
||||
$opt_x = undef; # extra debugging info
|
||||
$opt_p = undef; # proxy URL
|
||||
$opt_P = undef; # don't load proxy setting from environment
|
||||
|
||||
$opt_o = undef; # output format
|
||||
|
||||
unless (getopts("axhvuUsSedPp:b:t:i:c:C:m:fo:")) {
|
||||
usage();
|
||||
}
|
||||
|
||||
if ($opt_v) {
|
||||
require LWP;
|
||||
my $DISTNAME = 'libwww-perl-' . LWP::Version();
|
||||
die <<"EOT";
|
||||
This is lwp-request version $VERSION ($DISTNAME)
|
||||
|
||||
Copyright 1995-1997, Gisle Aas.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the same terms as Perl itself.
|
||||
EOT
|
||||
}
|
||||
|
||||
usage() if $opt_h || !@ARGV;
|
||||
|
||||
LWP::Debug::level('+') if $opt_x;
|
||||
|
||||
# Create the user agent object
|
||||
$ua = new RequestAgent;
|
||||
|
||||
# Load proxy settings from *_proxy environment variables.
|
||||
$ua->env_proxy unless $opt_P;
|
||||
|
||||
$method = uc($opt_m) if defined $opt_m;
|
||||
|
||||
if ($opt_f) {
|
||||
if ($opt_c) {
|
||||
$allowed_methods{$method} = "C"; # force content
|
||||
} else {
|
||||
$allowed_methods{$method} = "";
|
||||
}
|
||||
} elsif (!defined $allowed_methods{$method}) {
|
||||
die "$progname: $method is not an allowed method\n";
|
||||
}
|
||||
|
||||
if ($method eq "HEAD") {
|
||||
$opt_s = 1;
|
||||
$opt_e = 1 unless $opt_d;
|
||||
$opt_d = 1;
|
||||
}
|
||||
|
||||
if (defined $opt_t) {
|
||||
$opt_t =~ /^(\d+)([smh])?/;
|
||||
die "$progname: Illegal timeout value!\n" unless defined $1;
|
||||
$timeout = $1;
|
||||
$timeout *= 60 if ($2 eq "m");
|
||||
$timeout *= 3600 if ($2 eq "h");
|
||||
$ua->timeout($timeout);
|
||||
}
|
||||
|
||||
if (defined $opt_i) {
|
||||
if (-e $opt_i) {
|
||||
$time = (stat _)[9];
|
||||
} else {
|
||||
$time = str2time($opt_i);
|
||||
die "$progname: Illegal time syntax for -i option\n"
|
||||
unless defined $time;
|
||||
}
|
||||
$opt_i = time2str($time);
|
||||
}
|
||||
|
||||
$content = undef;
|
||||
if ($allowed_methods{$method} eq "C") {
|
||||
# This request needs some content
|
||||
unless (defined $opt_c) {
|
||||
# set default content type
|
||||
$opt_c = ($method eq "POST") ?
|
||||
"application/x-www-form-urlencoded"
|
||||
: "text/plain";
|
||||
} else {
|
||||
die "$progname: Illegal Content-type format\n"
|
||||
unless $opt_c =~ m,^[\w\-]+/[\w\-]+(?:\s*;.*)?$,
|
||||
}
|
||||
print "Please enter content ($opt_c) to be ${method}ed:\n"
|
||||
if -t;
|
||||
binmode STDIN unless -t or $opt_a;
|
||||
$content = join("", <STDIN>);
|
||||
} else {
|
||||
die "$progname: Can't set Content-type for $method requests\n"
|
||||
if defined $opt_c;
|
||||
}
|
||||
|
||||
# Set up a request. We will use the same request object for all URLs.
|
||||
$request = new HTTP::Request $method;
|
||||
$request->header('If-Modified-Since', $opt_i) if defined $opt_i;
|
||||
#$request->header('Accept', '*/*');
|
||||
if ($opt_c) { # will always be set for request that wants content
|
||||
$request->header('Content-Type', $opt_c);
|
||||
$request->header('Content-Length', length $content); # Not really needed
|
||||
$request->content($content);
|
||||
}
|
||||
|
||||
|
||||
$errors = 0;
|
||||
|
||||
# Ok, now we perform the requests, one URL at a time
|
||||
while ($url = shift) {
|
||||
# Create the URL object, but protect us against bad URLs
|
||||
eval {
|
||||
if ($url =~ /^\w+:/ || $opt_b) { # is there any scheme specification
|
||||
$url = URI::URL->new($url, $opt_b);
|
||||
} else {
|
||||
$url = uf_url($url);
|
||||
}
|
||||
};
|
||||
if ($@) {
|
||||
$@ =~ s/at\s+\S+\s+line\s\d+//;
|
||||
print STDERR $@;
|
||||
$errors++;
|
||||
next;
|
||||
}
|
||||
|
||||
$ua->proxy($url->scheme, $opt_p) if $opt_p;
|
||||
|
||||
# Send the request and get a response back from the server
|
||||
$request->url($url);
|
||||
$response = $ua->request($request);
|
||||
|
||||
if ($opt_u || $opt_U) {
|
||||
my $url = $response->request->url->as_string;
|
||||
print "$method $url\n";
|
||||
print $response->request->headers_as_string, "\n" if $opt_U;
|
||||
}
|
||||
|
||||
if ($opt_S) {
|
||||
printResponseChain($response);
|
||||
} elsif ($opt_s) {
|
||||
print $response->status_line, "\n";
|
||||
}
|
||||
|
||||
if ($opt_e) {
|
||||
# Display headers
|
||||
print $response->headers_as_string;
|
||||
print "\n"; # separate headers and content
|
||||
}
|
||||
|
||||
if ($response->is_success) {
|
||||
unless ($opt_d) {
|
||||
if ($opt_o &&
|
||||
$response->content_type eq 'text/html') {
|
||||
require HTML::Parse;
|
||||
my $html = HTML::Parse::parse_html($response->content);
|
||||
{
|
||||
$opt_o eq 'ps' && do {
|
||||
require HTML::FormatPS;
|
||||
my $f = new HTML::FormatPS;
|
||||
print $f->format($html);
|
||||
last;
|
||||
};
|
||||
$opt_o eq 'text' && do {
|
||||
require HTML::FormatText;
|
||||
my $f = new HTML::FormatText;
|
||||
print $f->format($html);
|
||||
last;
|
||||
};
|
||||
$opt_o eq 'html' && do {
|
||||
print $html->as_HTML;
|
||||
last;
|
||||
};
|
||||
$opt_o eq 'links' && do {
|
||||
my $base = $response->base;
|
||||
for ( @{ $html->extract_links } ) {
|
||||
my($link, $elem) = @$_;
|
||||
my $tag = uc $elem->tag;
|
||||
$link = new URI::URL $link, $base;
|
||||
print "$tag\t", $link->abs->as_string, "\n";
|
||||
}
|
||||
last;
|
||||
};
|
||||
$opt_o eq 'dump' && do {
|
||||
$html->dump;
|
||||
last;
|
||||
};
|
||||
# It is bad to not notice this before now :-(
|
||||
die "Illegal -o option value ($opt_o)\n";
|
||||
}
|
||||
} else {
|
||||
binmode STDOUT unless $opt_a;
|
||||
print $response->content;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print STDERR $response->error_as_HTML unless $opt_d;
|
||||
$errors++;
|
||||
}
|
||||
}
|
||||
|
||||
exit $errors;
|
||||
|
||||
|
||||
sub printResponseChain
|
||||
{
|
||||
my($response) = @_;
|
||||
return unless defined $response;
|
||||
printResponseChain($response->previous);
|
||||
my $method = $response->request->method;
|
||||
my $url = $response->request->url->as_string;
|
||||
my $code = $response->code;
|
||||
print "$method $url --> ", $response->status_line, "\n";
|
||||
}
|
||||
|
||||
|
||||
sub usage
|
||||
{
|
||||
die <<"EOT";
|
||||
Usage: $progname [-options] <url>...
|
||||
-m <method> use method for the request (default is '$method')
|
||||
-f make request even if $progname believes method is illegal
|
||||
-b <base> Use the specified URL as base
|
||||
-t <timeout> Set timeout value
|
||||
-i <time> Set the If-Modified-Since header on the request
|
||||
-c <conttype> use this content-type for POST, PUT, CHECKIN
|
||||
-a Use text mode for content I/O
|
||||
-p <proxyurl> use this as a proxy
|
||||
-P don't load proxy settings from environment
|
||||
|
||||
-u Display method and URL before any response
|
||||
-U Display request headers (implies -u)
|
||||
-s Display response status code
|
||||
-S Display response status chain
|
||||
-e Display response headers
|
||||
-d Do not display content
|
||||
-o <format> Process HTML content in various ways
|
||||
|
||||
-v Show program version
|
||||
-h Print this message
|
||||
|
||||
-x Extra debugging output
|
||||
EOT
|
||||
}
|
505
tools/Perl/bin/HEAD
Normal file
505
tools/Perl/bin/HEAD
Normal file
|
@ -0,0 +1,505 @@
|
|||
#!perl -w
|
||||
|
||||
# $Id: lwp-request.PL,v 1.33 1998/08/04 09:18:11 aas Exp $
|
||||
#
|
||||
# Simple user agent using LWP library.
|
||||
|
||||
=head1 NAME
|
||||
|
||||
lwp-request, GET, HEAD, POST - Simple WWW user agent
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
lwp-request [-aeEdvhx] [-m method] [-b <base URL>] [-t <timeout>]
|
||||
[-i <if-modified-since>] [-c <content-type>] [-C <credentials>]
|
||||
[-p <proxy-url>] [-o <format>] <url>...
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This program can be used to send requests to WWW servers and your
|
||||
local file system. The request content for POST, PUT and CHECKIN
|
||||
methods is read from stdin. The content of the response is printed on
|
||||
stdout. Error messages are printed on stderr. The program returns a
|
||||
status value indicating the number of URLs that failed.
|
||||
|
||||
The options are:
|
||||
|
||||
=over 4
|
||||
|
||||
=item -m <method>
|
||||
|
||||
Set which method to use for the request. If this option is not used,
|
||||
then the method is derived from the name of the program.
|
||||
|
||||
=item -f
|
||||
|
||||
Force request through, even if the program believes that the method is
|
||||
illegal. The server will probably reject the request.
|
||||
|
||||
=item -b <url>
|
||||
|
||||
This URL will be used as the base URL for the URLs that the method is
|
||||
applied to. The base URL only takes effect for relative URLs. If you
|
||||
do not provide this option and the URLs are relative, then they will
|
||||
be treated as files in the local file system.
|
||||
|
||||
=item -t <timeout>
|
||||
|
||||
Set the timeout value for the requests. The timeout is the amount of
|
||||
time that the program will wait for a response from the remote server
|
||||
before it fails. The default unit for the timeout value is seconds.
|
||||
You might append "m" or "h" to the timeout value to make it minutes or
|
||||
hours, respectively. The default timeout is '3m', i.e. 3 minutes.
|
||||
|
||||
=item -i <time>
|
||||
|
||||
Set the If-Modified-Since header in the request. If I<time> it the
|
||||
name of a file, use the modification timestamp for this file. If
|
||||
I<time> is not a file, it is parsed as a literal date. Take a look at
|
||||
L<HTTP::Date> for recogniced formats.
|
||||
|
||||
=item -c <content-type>
|
||||
|
||||
Set the Content-Type for the request. This option is only allowed for
|
||||
requests that take a content, i.e. POST, PUT and CHECKIN. You can
|
||||
force methods to take content by using the C<-f> option together with
|
||||
C<-c>. The default Content-Type for POST is
|
||||
C<application/x-www-form-urlencoded>. The default Content-type for
|
||||
the others is C<text/plain>.
|
||||
|
||||
=item -p <proxy-url>
|
||||
|
||||
Set the proxy to be used for the requests. The program also loads
|
||||
proxy settings from the environment. You can disable this with the
|
||||
C<-P> option.
|
||||
|
||||
=item -C <username>:<password>
|
||||
|
||||
Provide credentials for documents that are protected by Basic
|
||||
Authentication. If the document is protected and you did not specify
|
||||
the username and password with this option, then you will be prompted
|
||||
to provide these values.
|
||||
|
||||
=back
|
||||
|
||||
The following options controls what is displayed by the program:
|
||||
|
||||
=over 4
|
||||
|
||||
=item -u
|
||||
|
||||
Print request method and absolute URL as requests are made.
|
||||
|
||||
=item -U
|
||||
|
||||
Print request headers in addition to request method and absolute URL.
|
||||
|
||||
=item -s
|
||||
|
||||
Print response status code. This option is always on for HEAD requests.
|
||||
|
||||
=item -S
|
||||
|
||||
Print response status chain. This shows redirect and autorization
|
||||
requests that are handled by the library.
|
||||
|
||||
=item -e
|
||||
|
||||
Print response headers. This option is always on for HEAD requests.
|
||||
|
||||
=item -d
|
||||
|
||||
Do B<not> print the content of the response.
|
||||
|
||||
=item -o <format>
|
||||
|
||||
Process HTML content in various ways before printing it. If the
|
||||
content type of the response is not HTML, then this option has no
|
||||
effect. The legal format values are; I<text>, I<ps>, I<links>,
|
||||
I<html> and I<dump>.
|
||||
|
||||
If you specify the I<text> format then the HTML will be formatted as
|
||||
plain latin1 text. If you specify the I<ps> format then it will be
|
||||
formatted as Postscript.
|
||||
|
||||
The I<links> format will output all links found in the HTML document.
|
||||
Relative links will be expanded to absolute ones.
|
||||
|
||||
The I<html> format will reformat the HTML code and the I<dump> format
|
||||
will just dump the HTML syntax tree.
|
||||
|
||||
=item -v
|
||||
|
||||
Print the version number of the program and quit.
|
||||
|
||||
=item -h
|
||||
|
||||
Print usage message and quit.
|
||||
|
||||
=item -x
|
||||
|
||||
Extra debugging output.
|
||||
|
||||
=item -a
|
||||
|
||||
Set text(ascii) mode for content input and output. If this option is not
|
||||
used, content input and output is done in binary mode.
|
||||
|
||||
=back
|
||||
|
||||
Because this program is implemented using the LWP library, it will
|
||||
only support the protocols that LWP supports.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<lwp-mirror>, L<LWP>
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright 1995-1997 Gisle Aas.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the same terms as Perl itself.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Gisle Aas <aas@sn.no>
|
||||
|
||||
=cut
|
||||
|
||||
$progname = $0;
|
||||
$progname =~ s,.*/,,; # use basename only
|
||||
$progname =~ s/\.\w*$//; # strip extension, if any
|
||||
|
||||
$VERSION = sprintf("%d.%02d", q$Revision: 1.33 $ =~ /(\d+)\.(\d+)/);
|
||||
|
||||
|
||||
require LWP;
|
||||
require LWP::Debug;
|
||||
require URI::URL;
|
||||
|
||||
use URI::Heuristic qw(uf_url);
|
||||
|
||||
use HTTP::Status qw(status_message);
|
||||
use HTTP::Date qw(time2str str2time);
|
||||
|
||||
|
||||
# This table lists the methods that are allowed. It should really be
|
||||
# a superset for all methods supported for every scheme that may be
|
||||
# supported by the library. Currently it might be a bit too HTTP
|
||||
# specific. You might use the -f option to force a method through.
|
||||
#
|
||||
# "" = No content in request, "C" = Needs content in request
|
||||
#
|
||||
%allowed_methods = (
|
||||
GET => "",
|
||||
HEAD => "",
|
||||
POST => "C",
|
||||
PUT => "C",
|
||||
DELETE => "",
|
||||
TRACE => "",
|
||||
OPTIONS => "",
|
||||
);
|
||||
|
||||
|
||||
# We make our own specialization of LWP::UserAgent that asks for
|
||||
# user/password if document is protected.
|
||||
{
|
||||
package RequestAgent;
|
||||
@ISA = qw(LWP::UserAgent);
|
||||
|
||||
sub new
|
||||
{
|
||||
my $self = LWP::UserAgent::new(@_);
|
||||
$self->agent("lwp-request/$main::VERSION");
|
||||
$self;
|
||||
}
|
||||
|
||||
sub get_basic_credentials
|
||||
{
|
||||
my($self, $realm, $uri) = @_;
|
||||
if ($main::opt_C) {
|
||||
return split(':', $main::opt_C, 2);
|
||||
} elsif (-t) {
|
||||
my $netloc = $uri->netloc;
|
||||
print "Enter username for $realm at $netloc: ";
|
||||
my $user = <STDIN>;
|
||||
chomp($user);
|
||||
return (undef, undef) unless length $user;
|
||||
print "Password: ";
|
||||
system("stty -echo");
|
||||
my $password = <STDIN>;
|
||||
system("stty echo");
|
||||
print "\n"; # because we disabled echo
|
||||
chomp($password);
|
||||
return ($user, $password);
|
||||
} else {
|
||||
return (undef, undef)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$method = uc(lc($progname) eq "lwp-request" ? "GET" : $progname);
|
||||
|
||||
# Parse command line
|
||||
use Getopt::Std;
|
||||
|
||||
$opt_a = undef; # content i/o in text(ascii) mode
|
||||
$opt_m = undef; # set method
|
||||
$opt_f = undef; # make request even if method is not in %allowed_methods
|
||||
$opt_b = undef; # base url
|
||||
$opt_t = undef; # timeout
|
||||
$opt_i = undef; # if-modified-since
|
||||
$opt_c = undef; # content type for POST
|
||||
$opt_C = undef; # credidentials for basic authorization
|
||||
|
||||
$opt_u = undef; # display method, URL and headers of request
|
||||
$opt_U = undef; # display request headers also
|
||||
$opt_s = undef; # display status code
|
||||
$opt_S = undef; # display whole chain of status codes
|
||||
$opt_e = undef; # display response headers (default for HEAD)
|
||||
$opt_d = undef; # don't display content
|
||||
|
||||
$opt_h = undef; # print usage
|
||||
$opt_v = undef; # print version
|
||||
|
||||
$opt_x = undef; # extra debugging info
|
||||
$opt_p = undef; # proxy URL
|
||||
$opt_P = undef; # don't load proxy setting from environment
|
||||
|
||||
$opt_o = undef; # output format
|
||||
|
||||
unless (getopts("axhvuUsSedPp:b:t:i:c:C:m:fo:")) {
|
||||
usage();
|
||||
}
|
||||
|
||||
if ($opt_v) {
|
||||
require LWP;
|
||||
my $DISTNAME = 'libwww-perl-' . LWP::Version();
|
||||
die <<"EOT";
|
||||
This is lwp-request version $VERSION ($DISTNAME)
|
||||
|
||||
Copyright 1995-1997, Gisle Aas.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the same terms as Perl itself.
|
||||
EOT
|
||||
}
|
||||
|
||||
usage() if $opt_h || !@ARGV;
|
||||
|
||||
LWP::Debug::level('+') if $opt_x;
|
||||
|
||||
# Create the user agent object
|
||||
$ua = new RequestAgent;
|
||||
|
||||
# Load proxy settings from *_proxy environment variables.
|
||||
$ua->env_proxy unless $opt_P;
|
||||
|
||||
$method = uc($opt_m) if defined $opt_m;
|
||||
|
||||
if ($opt_f) {
|
||||
if ($opt_c) {
|
||||
$allowed_methods{$method} = "C"; # force content
|
||||
} else {
|
||||
$allowed_methods{$method} = "";
|
||||
}
|
||||
} elsif (!defined $allowed_methods{$method}) {
|
||||
die "$progname: $method is not an allowed method\n";
|
||||
}
|
||||
|
||||
if ($method eq "HEAD") {
|
||||
$opt_s = 1;
|
||||
$opt_e = 1 unless $opt_d;
|
||||
$opt_d = 1;
|
||||
}
|
||||
|
||||
if (defined $opt_t) {
|
||||
$opt_t =~ /^(\d+)([smh])?/;
|
||||
die "$progname: Illegal timeout value!\n" unless defined $1;
|
||||
$timeout = $1;
|
||||
$timeout *= 60 if ($2 eq "m");
|
||||
$timeout *= 3600 if ($2 eq "h");
|
||||
$ua->timeout($timeout);
|
||||
}
|
||||
|
||||
if (defined $opt_i) {
|
||||
if (-e $opt_i) {
|
||||
$time = (stat _)[9];
|
||||
} else {
|
||||
$time = str2time($opt_i);
|
||||
die "$progname: Illegal time syntax for -i option\n"
|
||||
unless defined $time;
|
||||
}
|
||||
$opt_i = time2str($time);
|
||||
}
|
||||
|
||||
$content = undef;
|
||||
if ($allowed_methods{$method} eq "C") {
|
||||
# This request needs some content
|
||||
unless (defined $opt_c) {
|
||||
# set default content type
|
||||
$opt_c = ($method eq "POST") ?
|
||||
"application/x-www-form-urlencoded"
|
||||
: "text/plain";
|
||||
} else {
|
||||
die "$progname: Illegal Content-type format\n"
|
||||
unless $opt_c =~ m,^[\w\-]+/[\w\-]+(?:\s*;.*)?$,
|
||||
}
|
||||
print "Please enter content ($opt_c) to be ${method}ed:\n"
|
||||
if -t;
|
||||
binmode STDIN unless -t or $opt_a;
|
||||
$content = join("", <STDIN>);
|
||||
} else {
|
||||
die "$progname: Can't set Content-type for $method requests\n"
|
||||
if defined $opt_c;
|
||||
}
|
||||
|
||||
# Set up a request. We will use the same request object for all URLs.
|
||||
$request = new HTTP::Request $method;
|
||||
$request->header('If-Modified-Since', $opt_i) if defined $opt_i;
|
||||
#$request->header('Accept', '*/*');
|
||||
if ($opt_c) { # will always be set for request that wants content
|
||||
$request->header('Content-Type', $opt_c);
|
||||
$request->header('Content-Length', length $content); # Not really needed
|
||||
$request->content($content);
|
||||
}
|
||||
|
||||
|
||||
$errors = 0;
|
||||
|
||||
# Ok, now we perform the requests, one URL at a time
|
||||
while ($url = shift) {
|
||||
# Create the URL object, but protect us against bad URLs
|
||||
eval {
|
||||
if ($url =~ /^\w+:/ || $opt_b) { # is there any scheme specification
|
||||
$url = URI::URL->new($url, $opt_b);
|
||||
} else {
|
||||
$url = uf_url($url);
|
||||
}
|
||||
};
|
||||
if ($@) {
|
||||
$@ =~ s/at\s+\S+\s+line\s\d+//;
|
||||
print STDERR $@;
|
||||
$errors++;
|
||||
next;
|
||||
}
|
||||
|
||||
$ua->proxy($url->scheme, $opt_p) if $opt_p;
|
||||
|
||||
# Send the request and get a response back from the server
|
||||
$request->url($url);
|
||||
$response = $ua->request($request);
|
||||
|
||||
if ($opt_u || $opt_U) {
|
||||
my $url = $response->request->url->as_string;
|
||||
print "$method $url\n";
|
||||
print $response->request->headers_as_string, "\n" if $opt_U;
|
||||
}
|
||||
|
||||
if ($opt_S) {
|
||||
printResponseChain($response);
|
||||
} elsif ($opt_s) {
|
||||
print $response->status_line, "\n";
|
||||
}
|
||||
|
||||
if ($opt_e) {
|
||||
# Display headers
|
||||
print $response->headers_as_string;
|
||||
print "\n"; # separate headers and content
|
||||
}
|
||||
|
||||
if ($response->is_success) {
|
||||
unless ($opt_d) {
|
||||
if ($opt_o &&
|
||||
$response->content_type eq 'text/html') {
|
||||
require HTML::Parse;
|
||||
my $html = HTML::Parse::parse_html($response->content);
|
||||
{
|
||||
$opt_o eq 'ps' && do {
|
||||
require HTML::FormatPS;
|
||||
my $f = new HTML::FormatPS;
|
||||
print $f->format($html);
|
||||
last;
|
||||
};
|
||||
$opt_o eq 'text' && do {
|
||||
require HTML::FormatText;
|
||||
my $f = new HTML::FormatText;
|
||||
print $f->format($html);
|
||||
last;
|
||||
};
|
||||
$opt_o eq 'html' && do {
|
||||
print $html->as_HTML;
|
||||
last;
|
||||
};
|
||||
$opt_o eq 'links' && do {
|
||||
my $base = $response->base;
|
||||
for ( @{ $html->extract_links } ) {
|
||||
my($link, $elem) = @$_;
|
||||
my $tag = uc $elem->tag;
|
||||
$link = new URI::URL $link, $base;
|
||||
print "$tag\t", $link->abs->as_string, "\n";
|
||||
}
|
||||
last;
|
||||
};
|
||||
$opt_o eq 'dump' && do {
|
||||
$html->dump;
|
||||
last;
|
||||
};
|
||||
# It is bad to not notice this before now :-(
|
||||
die "Illegal -o option value ($opt_o)\n";
|
||||
}
|
||||
} else {
|
||||
binmode STDOUT unless $opt_a;
|
||||
print $response->content;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print STDERR $response->error_as_HTML unless $opt_d;
|
||||
$errors++;
|
||||
}
|
||||
}
|
||||
|
||||
exit $errors;
|
||||
|
||||
|
||||
sub printResponseChain
|
||||
{
|
||||
my($response) = @_;
|
||||
return unless defined $response;
|
||||
printResponseChain($response->previous);
|
||||
my $method = $response->request->method;
|
||||
my $url = $response->request->url->as_string;
|
||||
my $code = $response->code;
|
||||
print "$method $url --> ", $response->status_line, "\n";
|
||||
}
|
||||
|
||||
|
||||
sub usage
|
||||
{
|
||||
die <<"EOT";
|
||||
Usage: $progname [-options] <url>...
|
||||
-m <method> use method for the request (default is '$method')
|
||||
-f make request even if $progname believes method is illegal
|
||||
-b <base> Use the specified URL as base
|
||||
-t <timeout> Set timeout value
|
||||
-i <time> Set the If-Modified-Since header on the request
|
||||
-c <conttype> use this content-type for POST, PUT, CHECKIN
|
||||
-a Use text mode for content I/O
|
||||
-p <proxyurl> use this as a proxy
|
||||
-P don't load proxy settings from environment
|
||||
|
||||
-u Display method and URL before any response
|
||||
-U Display request headers (implies -u)
|
||||
-s Display response status code
|
||||
-S Display response status chain
|
||||
-e Display response headers
|
||||
-d Do not display content
|
||||
-o <format> Process HTML content in various ways
|
||||
|
||||
-v Show program version
|
||||
-h Print this message
|
||||
|
||||
-x Extra debugging output
|
||||
EOT
|
||||
}
|
505
tools/Perl/bin/POST
Normal file
505
tools/Perl/bin/POST
Normal file
|
@ -0,0 +1,505 @@
|
|||
#!perl -w
|
||||
|
||||
# $Id: lwp-request.PL,v 1.33 1998/08/04 09:18:11 aas Exp $
|
||||
#
|
||||
# Simple user agent using LWP library.
|
||||
|
||||
=head1 NAME
|
||||
|
||||
lwp-request, GET, HEAD, POST - Simple WWW user agent
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
lwp-request [-aeEdvhx] [-m method] [-b <base URL>] [-t <timeout>]
|
||||
[-i <if-modified-since>] [-c <content-type>] [-C <credentials>]
|
||||
[-p <proxy-url>] [-o <format>] <url>...
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This program can be used to send requests to WWW servers and your
|
||||
local file system. The request content for POST, PUT and CHECKIN
|
||||
methods is read from stdin. The content of the response is printed on
|
||||
stdout. Error messages are printed on stderr. The program returns a
|
||||
status value indicating the number of URLs that failed.
|
||||
|
||||
The options are:
|
||||
|
||||
=over 4
|
||||
|
||||
=item -m <method>
|
||||
|
||||
Set which method to use for the request. If this option is not used,
|
||||
then the method is derived from the name of the program.
|
||||
|
||||
=item -f
|
||||
|
||||
Force request through, even if the program believes that the method is
|
||||
illegal. The server will probably reject the request.
|
||||
|
||||
=item -b <url>
|
||||
|
||||
This URL will be used as the base URL for the URLs that the method is
|
||||
applied to. The base URL only takes effect for relative URLs. If you
|
||||
do not provide this option and the URLs are relative, then they will
|
||||
be treated as files in the local file system.
|
||||
|
||||
=item -t <timeout>
|
||||
|
||||
Set the timeout value for the requests. The timeout is the amount of
|
||||
time that the program will wait for a response from the remote server
|
||||
before it fails. The default unit for the timeout value is seconds.
|
||||
You might append "m" or "h" to the timeout value to make it minutes or
|
||||
hours, respectively. The default timeout is '3m', i.e. 3 minutes.
|
||||
|
||||
=item -i <time>
|
||||
|
||||
Set the If-Modified-Since header in the request. If I<time> it the
|
||||
name of a file, use the modification timestamp for this file. If
|
||||
I<time> is not a file, it is parsed as a literal date. Take a look at
|
||||
L<HTTP::Date> for recogniced formats.
|
||||
|
||||
=item -c <content-type>
|
||||
|
||||
Set the Content-Type for the request. This option is only allowed for
|
||||
requests that take a content, i.e. POST, PUT and CHECKIN. You can
|
||||
force methods to take content by using the C<-f> option together with
|
||||
C<-c>. The default Content-Type for POST is
|
||||
C<application/x-www-form-urlencoded>. The default Content-type for
|
||||
the others is C<text/plain>.
|
||||
|
||||
=item -p <proxy-url>
|
||||
|
||||
Set the proxy to be used for the requests. The program also loads
|
||||
proxy settings from the environment. You can disable this with the
|
||||
C<-P> option.
|
||||
|
||||
=item -C <username>:<password>
|
||||
|
||||
Provide credentials for documents that are protected by Basic
|
||||
Authentication. If the document is protected and you did not specify
|
||||
the username and password with this option, then you will be prompted
|
||||
to provide these values.
|
||||
|
||||
=back
|
||||
|
||||
The following options controls what is displayed by the program:
|
||||
|
||||
=over 4
|
||||
|
||||
=item -u
|
||||
|
||||
Print request method and absolute URL as requests are made.
|
||||
|
||||
=item -U
|
||||
|
||||
Print request headers in addition to request method and absolute URL.
|
||||
|
||||
=item -s
|
||||
|
||||
Print response status code. This option is always on for HEAD requests.
|
||||
|
||||
=item -S
|
||||
|
||||
Print response status chain. This shows redirect and autorization
|
||||
requests that are handled by the library.
|
||||
|
||||
=item -e
|
||||
|
||||
Print response headers. This option is always on for HEAD requests.
|
||||
|
||||
=item -d
|
||||
|
||||
Do B<not> print the content of the response.
|
||||
|
||||
=item -o <format>
|
||||
|
||||
Process HTML content in various ways before printing it. If the
|
||||
content type of the response is not HTML, then this option has no
|
||||
effect. The legal format values are; I<text>, I<ps>, I<links>,
|
||||
I<html> and I<dump>.
|
||||
|
||||
If you specify the I<text> format then the HTML will be formatted as
|
||||
plain latin1 text. If you specify the I<ps> format then it will be
|
||||
formatted as Postscript.
|
||||
|
||||
The I<links> format will output all links found in the HTML document.
|
||||
Relative links will be expanded to absolute ones.
|
||||
|
||||
The I<html> format will reformat the HTML code and the I<dump> format
|
||||
will just dump the HTML syntax tree.
|
||||
|
||||
=item -v
|
||||
|
||||
Print the version number of the program and quit.
|
||||
|
||||
=item -h
|
||||
|
||||
Print usage message and quit.
|
||||
|
||||
=item -x
|
||||
|
||||
Extra debugging output.
|
||||
|
||||
=item -a
|
||||
|
||||
Set text(ascii) mode for content input and output. If this option is not
|
||||
used, content input and output is done in binary mode.
|
||||
|
||||
=back
|
||||
|
||||
Because this program is implemented using the LWP library, it will
|
||||
only support the protocols that LWP supports.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<lwp-mirror>, L<LWP>
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright 1995-1997 Gisle Aas.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the same terms as Perl itself.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Gisle Aas <aas@sn.no>
|
||||
|
||||
=cut
|
||||
|
||||
$progname = $0;
|
||||
$progname =~ s,.*/,,; # use basename only
|
||||
$progname =~ s/\.\w*$//; # strip extension, if any
|
||||
|
||||
$VERSION = sprintf("%d.%02d", q$Revision: 1.33 $ =~ /(\d+)\.(\d+)/);
|
||||
|
||||
|
||||
require LWP;
|
||||
require LWP::Debug;
|
||||
require URI::URL;
|
||||
|
||||
use URI::Heuristic qw(uf_url);
|
||||
|
||||
use HTTP::Status qw(status_message);
|
||||
use HTTP::Date qw(time2str str2time);
|
||||
|
||||
|
||||
# This table lists the methods that are allowed. It should really be
|
||||
# a superset for all methods supported for every scheme that may be
|
||||
# supported by the library. Currently it might be a bit too HTTP
|
||||
# specific. You might use the -f option to force a method through.
|
||||
#
|
||||
# "" = No content in request, "C" = Needs content in request
|
||||
#
|
||||
%allowed_methods = (
|
||||
GET => "",
|
||||
HEAD => "",
|
||||
POST => "C",
|
||||
PUT => "C",
|
||||
DELETE => "",
|
||||
TRACE => "",
|
||||
OPTIONS => "",
|
||||
);
|
||||
|
||||
|
||||
# We make our own specialization of LWP::UserAgent that asks for
|
||||
# user/password if document is protected.
|
||||
{
|
||||
package RequestAgent;
|
||||
@ISA = qw(LWP::UserAgent);
|
||||
|
||||
sub new
|
||||
{
|
||||
my $self = LWP::UserAgent::new(@_);
|
||||
$self->agent("lwp-request/$main::VERSION");
|
||||
$self;
|
||||
}
|
||||
|
||||
sub get_basic_credentials
|
||||
{
|
||||
my($self, $realm, $uri) = @_;
|
||||
if ($main::opt_C) {
|
||||
return split(':', $main::opt_C, 2);
|
||||
} elsif (-t) {
|
||||
my $netloc = $uri->netloc;
|
||||
print "Enter username for $realm at $netloc: ";
|
||||
my $user = <STDIN>;
|
||||
chomp($user);
|
||||
return (undef, undef) unless length $user;
|
||||
print "Password: ";
|
||||
system("stty -echo");
|
||||
my $password = <STDIN>;
|
||||
system("stty echo");
|
||||
print "\n"; # because we disabled echo
|
||||
chomp($password);
|
||||
return ($user, $password);
|
||||
} else {
|
||||
return (undef, undef)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$method = uc(lc($progname) eq "lwp-request" ? "GET" : $progname);
|
||||
|
||||
# Parse command line
|
||||
use Getopt::Std;
|
||||
|
||||
$opt_a = undef; # content i/o in text(ascii) mode
|
||||
$opt_m = undef; # set method
|
||||
$opt_f = undef; # make request even if method is not in %allowed_methods
|
||||
$opt_b = undef; # base url
|
||||
$opt_t = undef; # timeout
|
||||
$opt_i = undef; # if-modified-since
|
||||
$opt_c = undef; # content type for POST
|
||||
$opt_C = undef; # credidentials for basic authorization
|
||||
|
||||
$opt_u = undef; # display method, URL and headers of request
|
||||
$opt_U = undef; # display request headers also
|
||||
$opt_s = undef; # display status code
|
||||
$opt_S = undef; # display whole chain of status codes
|
||||
$opt_e = undef; # display response headers (default for HEAD)
|
||||
$opt_d = undef; # don't display content
|
||||
|
||||
$opt_h = undef; # print usage
|
||||
$opt_v = undef; # print version
|
||||
|
||||
$opt_x = undef; # extra debugging info
|
||||
$opt_p = undef; # proxy URL
|
||||
$opt_P = undef; # don't load proxy setting from environment
|
||||
|
||||
$opt_o = undef; # output format
|
||||
|
||||
unless (getopts("axhvuUsSedPp:b:t:i:c:C:m:fo:")) {
|
||||
usage();
|
||||
}
|
||||
|
||||
if ($opt_v) {
|
||||
require LWP;
|
||||
my $DISTNAME = 'libwww-perl-' . LWP::Version();
|
||||
die <<"EOT";
|
||||
This is lwp-request version $VERSION ($DISTNAME)
|
||||
|
||||
Copyright 1995-1997, Gisle Aas.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the same terms as Perl itself.
|
||||
EOT
|
||||
}
|
||||
|
||||
usage() if $opt_h || !@ARGV;
|
||||
|
||||
LWP::Debug::level('+') if $opt_x;
|
||||
|
||||
# Create the user agent object
|
||||
$ua = new RequestAgent;
|
||||
|
||||
# Load proxy settings from *_proxy environment variables.
|
||||
$ua->env_proxy unless $opt_P;
|
||||
|
||||
$method = uc($opt_m) if defined $opt_m;
|
||||
|
||||
if ($opt_f) {
|
||||
if ($opt_c) {
|
||||
$allowed_methods{$method} = "C"; # force content
|
||||
} else {
|
||||
$allowed_methods{$method} = "";
|
||||
}
|
||||
} elsif (!defined $allowed_methods{$method}) {
|
||||
die "$progname: $method is not an allowed method\n";
|
||||
}
|
||||
|
||||
if ($method eq "HEAD") {
|
||||
$opt_s = 1;
|
||||
$opt_e = 1 unless $opt_d;
|
||||
$opt_d = 1;
|
||||
}
|
||||
|
||||
if (defined $opt_t) {
|
||||
$opt_t =~ /^(\d+)([smh])?/;
|
||||
die "$progname: Illegal timeout value!\n" unless defined $1;
|
||||
$timeout = $1;
|
||||
$timeout *= 60 if ($2 eq "m");
|
||||
$timeout *= 3600 if ($2 eq "h");
|
||||
$ua->timeout($timeout);
|
||||
}
|
||||
|
||||
if (defined $opt_i) {
|
||||
if (-e $opt_i) {
|
||||
$time = (stat _)[9];
|
||||
} else {
|
||||
$time = str2time($opt_i);
|
||||
die "$progname: Illegal time syntax for -i option\n"
|
||||
unless defined $time;
|
||||
}
|
||||
$opt_i = time2str($time);
|
||||
}
|
||||
|
||||
$content = undef;
|
||||
if ($allowed_methods{$method} eq "C") {
|
||||
# This request needs some content
|
||||
unless (defined $opt_c) {
|
||||
# set default content type
|
||||
$opt_c = ($method eq "POST") ?
|
||||
"application/x-www-form-urlencoded"
|
||||
: "text/plain";
|
||||
} else {
|
||||
die "$progname: Illegal Content-type format\n"
|
||||
unless $opt_c =~ m,^[\w\-]+/[\w\-]+(?:\s*;.*)?$,
|
||||
}
|
||||
print "Please enter content ($opt_c) to be ${method}ed:\n"
|
||||
if -t;
|
||||
binmode STDIN unless -t or $opt_a;
|
||||
$content = join("", <STDIN>);
|
||||
} else {
|
||||
die "$progname: Can't set Content-type for $method requests\n"
|
||||
if defined $opt_c;
|
||||
}
|
||||
|
||||
# Set up a request. We will use the same request object for all URLs.
|
||||
$request = new HTTP::Request $method;
|
||||
$request->header('If-Modified-Since', $opt_i) if defined $opt_i;
|
||||
#$request->header('Accept', '*/*');
|
||||
if ($opt_c) { # will always be set for request that wants content
|
||||
$request->header('Content-Type', $opt_c);
|
||||
$request->header('Content-Length', length $content); # Not really needed
|
||||
$request->content($content);
|
||||
}
|
||||
|
||||
|
||||
$errors = 0;
|
||||
|
||||
# Ok, now we perform the requests, one URL at a time
|
||||
while ($url = shift) {
|
||||
# Create the URL object, but protect us against bad URLs
|
||||
eval {
|
||||
if ($url =~ /^\w+:/ || $opt_b) { # is there any scheme specification
|
||||
$url = URI::URL->new($url, $opt_b);
|
||||
} else {
|
||||
$url = uf_url($url);
|
||||
}
|
||||
};
|
||||
if ($@) {
|
||||
$@ =~ s/at\s+\S+\s+line\s\d+//;
|
||||
print STDERR $@;
|
||||
$errors++;
|
||||
next;
|
||||
}
|
||||
|
||||
$ua->proxy($url->scheme, $opt_p) if $opt_p;
|
||||
|
||||
# Send the request and get a response back from the server
|
||||
$request->url($url);
|
||||
$response = $ua->request($request);
|
||||
|
||||
if ($opt_u || $opt_U) {
|
||||
my $url = $response->request->url->as_string;
|
||||
print "$method $url\n";
|
||||
print $response->request->headers_as_string, "\n" if $opt_U;
|
||||
}
|
||||
|
||||
if ($opt_S) {
|
||||
printResponseChain($response);
|
||||
} elsif ($opt_s) {
|
||||
print $response->status_line, "\n";
|
||||
}
|
||||
|
||||
if ($opt_e) {
|
||||
# Display headers
|
||||
print $response->headers_as_string;
|
||||
print "\n"; # separate headers and content
|
||||
}
|
||||
|
||||
if ($response->is_success) {
|
||||
unless ($opt_d) {
|
||||
if ($opt_o &&
|
||||
$response->content_type eq 'text/html') {
|
||||
require HTML::Parse;
|
||||
my $html = HTML::Parse::parse_html($response->content);
|
||||
{
|
||||
$opt_o eq 'ps' && do {
|
||||
require HTML::FormatPS;
|
||||
my $f = new HTML::FormatPS;
|
||||
print $f->format($html);
|
||||
last;
|
||||
};
|
||||
$opt_o eq 'text' && do {
|
||||
require HTML::FormatText;
|
||||
my $f = new HTML::FormatText;
|
||||
print $f->format($html);
|
||||
last;
|
||||
};
|
||||
$opt_o eq 'html' && do {
|
||||
print $html->as_HTML;
|
||||
last;
|
||||
};
|
||||
$opt_o eq 'links' && do {
|
||||
my $base = $response->base;
|
||||
for ( @{ $html->extract_links } ) {
|
||||
my($link, $elem) = @$_;
|
||||
my $tag = uc $elem->tag;
|
||||
$link = new URI::URL $link, $base;
|
||||
print "$tag\t", $link->abs->as_string, "\n";
|
||||
}
|
||||
last;
|
||||
};
|
||||
$opt_o eq 'dump' && do {
|
||||
$html->dump;
|
||||
last;
|
||||
};
|
||||
# It is bad to not notice this before now :-(
|
||||
die "Illegal -o option value ($opt_o)\n";
|
||||
}
|
||||
} else {
|
||||
binmode STDOUT unless $opt_a;
|
||||
print $response->content;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print STDERR $response->error_as_HTML unless $opt_d;
|
||||
$errors++;
|
||||
}
|
||||
}
|
||||
|
||||
exit $errors;
|
||||
|
||||
|
||||
sub printResponseChain
|
||||
{
|
||||
my($response) = @_;
|
||||
return unless defined $response;
|
||||
printResponseChain($response->previous);
|
||||
my $method = $response->request->method;
|
||||
my $url = $response->request->url->as_string;
|
||||
my $code = $response->code;
|
||||
print "$method $url --> ", $response->status_line, "\n";
|
||||
}
|
||||
|
||||
|
||||
sub usage
|
||||
{
|
||||
die <<"EOT";
|
||||
Usage: $progname [-options] <url>...
|
||||
-m <method> use method for the request (default is '$method')
|
||||
-f make request even if $progname believes method is illegal
|
||||
-b <base> Use the specified URL as base
|
||||
-t <timeout> Set timeout value
|
||||
-i <time> Set the If-Modified-Since header on the request
|
||||
-c <conttype> use this content-type for POST, PUT, CHECKIN
|
||||
-a Use text mode for content I/O
|
||||
-p <proxyurl> use this as a proxy
|
||||
-P don't load proxy settings from environment
|
||||
|
||||
-u Display method and URL before any response
|
||||
-U Display request headers (implies -u)
|
||||
-s Display response status code
|
||||
-S Display response status chain
|
||||
-e Display response headers
|
||||
-d Do not display content
|
||||
-o <format> Process HTML content in various ways
|
||||
|
||||
-v Show program version
|
||||
-h Print this message
|
||||
|
||||
-x Extra debugging output
|
||||
EOT
|
||||
}
|
BIN
tools/Perl/bin/PerlCRT.dll
Normal file
BIN
tools/Perl/bin/PerlCRT.dll
Normal file
Binary file not shown.
BIN
tools/Perl/bin/PerlEz.dll
Normal file
BIN
tools/Perl/bin/PerlEz.dll
Normal file
Binary file not shown.
BIN
tools/Perl/bin/PerlMsg.dll
Normal file
BIN
tools/Perl/bin/PerlMsg.dll
Normal file
Binary file not shown.
BIN
tools/Perl/bin/PerlSE.dll
Normal file
BIN
tools/Perl/bin/PerlSE.dll
Normal file
Binary file not shown.
BIN
tools/Perl/bin/PerlSE.pl
Normal file
BIN
tools/Perl/bin/PerlSE.pl
Normal file
Binary file not shown.
BIN
tools/Perl/bin/a2p.exe
Normal file
BIN
tools/Perl/bin/a2p.exe
Normal file
Binary file not shown.
232
tools/Perl/bin/lwp-download
Normal file
232
tools/Perl/bin/lwp-download
Normal file
|
@ -0,0 +1,232 @@
|
|||
#!perl -w
|
||||
|
||||
# $Id: lwp-download.PL,v 1.7 1998/08/04 09:03:35 aas Exp $
|
||||
|
||||
=head1 NAME
|
||||
|
||||
lwp-download - fetch large files from the net
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
lwp-download [-a] <url> [<local file>]
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
The I<lwp-download> program will down load the document specified by the URL
|
||||
given as the first command line argument to a local file. The local
|
||||
filename used to save the document is guessed from the URL unless
|
||||
specified as the second command line argument.
|
||||
|
||||
The I<lwp-download> program is implemented using the I<libwww-perl>
|
||||
library. It is better suited to down load big files than the
|
||||
I<lwp-request> program because it does not store the file in memory.
|
||||
Another benefit is that it will keep you updated about its progress
|
||||
and that you don't have much options to worry about.
|
||||
|
||||
Use the C<-a> option to save the file in text (ascii) mode. Might make a
|
||||
difference on dosish systems.
|
||||
|
||||
=head1 EXAMPLE
|
||||
|
||||
Fetch the newest and greatest perl version:
|
||||
|
||||
$ lwp-download http://www.perl.com/CPAN/src/latest.tar.gz
|
||||
Saving to 'latest.tar.gz'...
|
||||
1.47 MB received in 22 seconds (68.7 KB/sec)
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Gisle Aas <gisle@aas.no>
|
||||
|
||||
=cut
|
||||
|
||||
use LWP::UserAgent;
|
||||
use LWP::MediaTypes;
|
||||
use URI::URL;
|
||||
use strict;
|
||||
|
||||
my $progname = $0;
|
||||
$progname =~ s,.*/,,; # only basename left in progname
|
||||
$progname =~ s/\.\w*$//; # strip extension if any
|
||||
|
||||
#parse option
|
||||
use Getopt::Std;
|
||||
my %opts;
|
||||
unless (getopts('a', \%opts)) {
|
||||
usage();
|
||||
}
|
||||
my $opt_a = $opts{a}; # save in binary mode
|
||||
|
||||
my $url = url(shift || usage());
|
||||
my $argfile = shift;
|
||||
|
||||
my $ua = new LWP::UserAgent;
|
||||
|
||||
$ua->agent("lwp-download/0.1 " . $ua->agent);
|
||||
$ua->env_proxy;
|
||||
|
||||
my $req = new HTTP::Request GET => $url;
|
||||
|
||||
my $file; # name of file we download into
|
||||
my $length; # total number of bytes to download
|
||||
my $flength; # formatted length
|
||||
my $size = 0; # number of bytes received
|
||||
my $start_t; # start time of download
|
||||
my $last_dur; # time of last callback
|
||||
|
||||
my $shown = 0; # have we called the show() function yet
|
||||
|
||||
$SIG{INT} = sub { die "Interrupted\n"; };
|
||||
|
||||
$| = 1; # autoflush
|
||||
|
||||
my $res = $ua->request($req,
|
||||
sub {
|
||||
unless($file) {
|
||||
my $res = $_[1];
|
||||
unless ($argfile) {
|
||||
# must find a suitable name to use. First thing
|
||||
# to do is to look for the "Content-Disposition"
|
||||
# header defined by RFC1806. This is also supported
|
||||
# by Netscape
|
||||
my $cd = $res->header("Content-Disposition");
|
||||
if ($cd && $cd =~ /\bfilename\s*=\s*(\S+)/) {
|
||||
$file = $1;
|
||||
$file =~ s/;$//;
|
||||
$file =~ s/^([\"\'])(.*)\1$/$2/;
|
||||
}
|
||||
|
||||
# if this fails we try to make something from the URL
|
||||
unless ($file) {
|
||||
my $req = $res->request; # now always there
|
||||
my $rurl = $req ? $req->url : $url;
|
||||
|
||||
$file = ($rurl->path_components)[-1];
|
||||
unless (length $file) {
|
||||
$file = "index";
|
||||
my $suffix = media_suffix($res->content_type);
|
||||
$file .= ".$suffix" if $suffix;
|
||||
} elsif ($rurl->scheme eq 'ftp' ||
|
||||
$file =~ /\.tgz$/ ||
|
||||
$file =~ /\.tar(\.(Z|gz))?$/
|
||||
) {
|
||||
# leave the filename as it was
|
||||
} else {
|
||||
my $ct = guess_media_type($file);
|
||||
unless ($ct eq $res->content_type) {
|
||||
# need a better suffix for this type
|
||||
my $suffix = media_suffix($res->content_type);
|
||||
$file .= ".$suffix" if $suffix;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Check if the file is already present
|
||||
if (-f $file && -t) {
|
||||
print "Overwrite $file? [y] ";
|
||||
my $ans = <STDIN>;
|
||||
exit if !defined($ans) || !($ans =~ /^y?\n/);
|
||||
} else {
|
||||
print "Saving to '$file'...\n";
|
||||
}
|
||||
} else {
|
||||
$file = $argfile;
|
||||
}
|
||||
open(FILE, ">$file") || die "Can't open $file: $!";
|
||||
binmode FILE unless $opt_a;
|
||||
$length = $res->content_length;
|
||||
$flength = fbytes($length) if defined $length;
|
||||
$start_t = time;
|
||||
$last_dur = 0;
|
||||
}
|
||||
$size += length($_[0]);
|
||||
print FILE $_[0];
|
||||
if (defined $length) {
|
||||
my $dur = time - $start_t;
|
||||
if ($dur != $last_dur) { # don't update too often
|
||||
$last_dur = $dur;
|
||||
my $perc = $size / $length;
|
||||
my $speed;
|
||||
$speed = fbytes($size/$dur) . "/sec" if $dur > 3;
|
||||
my $secs_left = fduration($dur/$perc - $dur);
|
||||
$perc = int($perc*100);
|
||||
my $show = "$perc% of $flength";
|
||||
$show .= " (at $speed, $secs_left remaining)" if $speed;
|
||||
show($show);
|
||||
}
|
||||
} else {
|
||||
show( fbytes($size) . " received");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if ($res->is_success || $res->message =~ /^Interrupted/) {
|
||||
show(""); # clear text
|
||||
print "\r";
|
||||
print fbytes($size);
|
||||
print " of ", fbytes($length) if defined($length) && $length != $size;
|
||||
print " received";
|
||||
my $dur = time - $start_t;
|
||||
if ($dur) {
|
||||
my $speed = fbytes($size/$dur) . "/sec";
|
||||
print " in ", fduration($dur), " ($speed)";
|
||||
}
|
||||
print "\n";
|
||||
my $died = $res->header("X-Died");
|
||||
if ($died || !$res->is_success) {
|
||||
if (-t) {
|
||||
print "Transfer aborted. Delete $file? [n] ";
|
||||
my $ans = <STDIN>;
|
||||
unlink($file) if defined($ans) && $ans =~ /^y\n/;
|
||||
} else {
|
||||
print "Transfer aborted, $file kept\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print "\n" if $shown;
|
||||
print "$progname: Can't download: ", $res->code, " ", $res->message, "\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
|
||||
sub fbytes
|
||||
{
|
||||
my $n = int(shift);
|
||||
if ($n >= 1024 * 1024) {
|
||||
return sprintf "%.3g MB", $n / (1024.0 * 1024);
|
||||
} elsif ($n >= 1024) {
|
||||
return sprintf "%.3g KB", $n / 1024.0;
|
||||
} else {
|
||||
return "$n bytes";
|
||||
}
|
||||
}
|
||||
|
||||
sub fduration
|
||||
{
|
||||
use integer;
|
||||
my $secs = int(shift);
|
||||
my $hours = $secs / (60*60);
|
||||
$secs -= $hours * 60*60;
|
||||
my $mins = $secs / 60;
|
||||
$secs %= 60;
|
||||
if ($hours) {
|
||||
return "$hours hours $mins minutes";
|
||||
} elsif ($mins >= 2) {
|
||||
return "$mins minutes";
|
||||
} else {
|
||||
$secs += $mins * 60;
|
||||
return "$secs seconds";
|
||||
}
|
||||
}
|
||||
|
||||
sub show
|
||||
{
|
||||
my $mess = shift;
|
||||
print "\r$mess", (" " x (75 - length $mess));
|
||||
$shown++;
|
||||
}
|
||||
|
||||
sub usage
|
||||
{
|
||||
die "Usage: $progname [-a] <url> [<lpath>]\n";
|
||||
}
|
104
tools/Perl/bin/lwp-mirror
Normal file
104
tools/Perl/bin/lwp-mirror
Normal file
|
@ -0,0 +1,104 @@
|
|||
#!perl -w
|
||||
|
||||
# $Id: lwp-mirror.PL,v 1.18 1997/12/03 21:21:00 aas Exp $
|
||||
#
|
||||
# Simple mirror utility using LWP
|
||||
|
||||
=head1 NAME
|
||||
|
||||
lwp-mirror - Simple mirror utility for WWW
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
lwp-mirror [-v] [-t timeout] <url> <local file>
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This program can be used to mirror a document from a WWW server. The
|
||||
document is only transfered if the remote copy is newer than the local
|
||||
copy. If the local copy is newer nothing happens.
|
||||
|
||||
Use the C<-v> option to print the version number of this program.
|
||||
|
||||
The timeout value specified with the C<-t> option. The timeout value
|
||||
is the time that the program will wait for response from the remote
|
||||
server before it fails. The default unit for the timeout value is
|
||||
seconds. You might append "m" or "h" to the timeout value to make it
|
||||
minutes or hours, repectively.
|
||||
|
||||
Because this program is implemented using the LWP library, it only
|
||||
supports the protocols that LWP supports.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<lwp-request>, L<LWP>
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Gisle Aas <aas@a.sn.no>
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
use LWP::Simple;
|
||||
use Getopt::Std;
|
||||
|
||||
$progname = $0;
|
||||
$progname =~ s,.*/,,; # use basename only
|
||||
$progname =~ s/\.\w*$//; #strip extension if any
|
||||
|
||||
$VERSION = sprintf("%d.%02d", q$Revision: 1.18 $ =~ /(\d+)\.(\d+)/);
|
||||
|
||||
$opt_h = undef; # print usage
|
||||
$opt_v = undef; # print version
|
||||
$opt_t = undef; # timeout
|
||||
|
||||
unless (getopts("hvt:")) {
|
||||
usage();
|
||||
}
|
||||
|
||||
if ($opt_v) {
|
||||
require LWP;
|
||||
my $DISTNAME = 'libwww-perl-' . LWP::Version();
|
||||
die <<"EOT";
|
||||
This is lwp-mirror version $VERSION ($DISTNAME)
|
||||
|
||||
Copyright 1995-1996, Gisle Aas.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the same terms as Perl itself.
|
||||
EOT
|
||||
}
|
||||
|
||||
$url = shift or usage();
|
||||
$file = shift or usage();
|
||||
usage() if $opt_h or @ARGV;
|
||||
|
||||
if (defined $opt_t) {
|
||||
$opt_t =~ /^(\d+)([smh])?/;
|
||||
die "$progname: Illegal timeout value!\n" unless defined $1;
|
||||
$timeout = $1;
|
||||
$timeout *= 60 if ($2 eq "m");
|
||||
$timeout *= 3600 if ($2 eq "h");
|
||||
$LWP::Simple::ua->timeout($timeout);
|
||||
}
|
||||
|
||||
$rc = mirror($url, $file);
|
||||
|
||||
if ($rc == 304) {
|
||||
print STDERR "$progname: $file is up to date\n"
|
||||
} elsif (!is_success($rc)) {
|
||||
print STDERR "$progname: $rc ", status_message($rc), " ($url)\n";
|
||||
exit 1;
|
||||
}
|
||||
exit;
|
||||
|
||||
|
||||
sub usage
|
||||
{
|
||||
die <<"EOT";
|
||||
Usage: $progname [-options] <url> <file>
|
||||
-v print version number of program
|
||||
-t <timeout> Set timeout value
|
||||
EOT
|
||||
}
|
505
tools/Perl/bin/lwp-request
Normal file
505
tools/Perl/bin/lwp-request
Normal file
|
@ -0,0 +1,505 @@
|
|||
#!perl -w
|
||||
|
||||
# $Id: lwp-request.PL,v 1.33 1998/08/04 09:18:11 aas Exp $
|
||||
#
|
||||
# Simple user agent using LWP library.
|
||||
|
||||
=head1 NAME
|
||||
|
||||
lwp-request, GET, HEAD, POST - Simple WWW user agent
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
lwp-request [-aeEdvhx] [-m method] [-b <base URL>] [-t <timeout>]
|
||||
[-i <if-modified-since>] [-c <content-type>] [-C <credentials>]
|
||||
[-p <proxy-url>] [-o <format>] <url>...
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This program can be used to send requests to WWW servers and your
|
||||
local file system. The request content for POST, PUT and CHECKIN
|
||||
methods is read from stdin. The content of the response is printed on
|
||||
stdout. Error messages are printed on stderr. The program returns a
|
||||
status value indicating the number of URLs that failed.
|
||||
|
||||
The options are:
|
||||
|
||||
=over 4
|
||||
|
||||
=item -m <method>
|
||||
|
||||
Set which method to use for the request. If this option is not used,
|
||||
then the method is derived from the name of the program.
|
||||
|
||||
=item -f
|
||||
|
||||
Force request through, even if the program believes that the method is
|
||||
illegal. The server will probably reject the request.
|
||||
|
||||
=item -b <url>
|
||||
|
||||
This URL will be used as the base URL for the URLs that the method is
|
||||
applied to. The base URL only takes effect for relative URLs. If you
|
||||
do not provide this option and the URLs are relative, then they will
|
||||
be treated as files in the local file system.
|
||||
|
||||
=item -t <timeout>
|
||||
|
||||
Set the timeout value for the requests. The timeout is the amount of
|
||||
time that the program will wait for a response from the remote server
|
||||
before it fails. The default unit for the timeout value is seconds.
|
||||
You might append "m" or "h" to the timeout value to make it minutes or
|
||||
hours, respectively. The default timeout is '3m', i.e. 3 minutes.
|
||||
|
||||
=item -i <time>
|
||||
|
||||
Set the If-Modified-Since header in the request. If I<time> it the
|
||||
name of a file, use the modification timestamp for this file. If
|
||||
I<time> is not a file, it is parsed as a literal date. Take a look at
|
||||
L<HTTP::Date> for recogniced formats.
|
||||
|
||||
=item -c <content-type>
|
||||
|
||||
Set the Content-Type for the request. This option is only allowed for
|
||||
requests that take a content, i.e. POST, PUT and CHECKIN. You can
|
||||
force methods to take content by using the C<-f> option together with
|
||||
C<-c>. The default Content-Type for POST is
|
||||
C<application/x-www-form-urlencoded>. The default Content-type for
|
||||
the others is C<text/plain>.
|
||||
|
||||
=item -p <proxy-url>
|
||||
|
||||
Set the proxy to be used for the requests. The program also loads
|
||||
proxy settings from the environment. You can disable this with the
|
||||
C<-P> option.
|
||||
|
||||
=item -C <username>:<password>
|
||||
|
||||
Provide credentials for documents that are protected by Basic
|
||||
Authentication. If the document is protected and you did not specify
|
||||
the username and password with this option, then you will be prompted
|
||||
to provide these values.
|
||||
|
||||
=back
|
||||
|
||||
The following options controls what is displayed by the program:
|
||||
|
||||
=over 4
|
||||
|
||||
=item -u
|
||||
|
||||
Print request method and absolute URL as requests are made.
|
||||
|
||||
=item -U
|
||||
|
||||
Print request headers in addition to request method and absolute URL.
|
||||
|
||||
=item -s
|
||||
|
||||
Print response status code. This option is always on for HEAD requests.
|
||||
|
||||
=item -S
|
||||
|
||||
Print response status chain. This shows redirect and autorization
|
||||
requests that are handled by the library.
|
||||
|
||||
=item -e
|
||||
|
||||
Print response headers. This option is always on for HEAD requests.
|
||||
|
||||
=item -d
|
||||
|
||||
Do B<not> print the content of the response.
|
||||
|
||||
=item -o <format>
|
||||
|
||||
Process HTML content in various ways before printing it. If the
|
||||
content type of the response is not HTML, then this option has no
|
||||
effect. The legal format values are; I<text>, I<ps>, I<links>,
|
||||
I<html> and I<dump>.
|
||||
|
||||
If you specify the I<text> format then the HTML will be formatted as
|
||||
plain latin1 text. If you specify the I<ps> format then it will be
|
||||
formatted as Postscript.
|
||||
|
||||
The I<links> format will output all links found in the HTML document.
|
||||
Relative links will be expanded to absolute ones.
|
||||
|
||||
The I<html> format will reformat the HTML code and the I<dump> format
|
||||
will just dump the HTML syntax tree.
|
||||
|
||||
=item -v
|
||||
|
||||
Print the version number of the program and quit.
|
||||
|
||||
=item -h
|
||||
|
||||
Print usage message and quit.
|
||||
|
||||
=item -x
|
||||
|
||||
Extra debugging output.
|
||||
|
||||
=item -a
|
||||
|
||||
Set text(ascii) mode for content input and output. If this option is not
|
||||
used, content input and output is done in binary mode.
|
||||
|
||||
=back
|
||||
|
||||
Because this program is implemented using the LWP library, it will
|
||||
only support the protocols that LWP supports.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<lwp-mirror>, L<LWP>
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright 1995-1997 Gisle Aas.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the same terms as Perl itself.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Gisle Aas <aas@sn.no>
|
||||
|
||||
=cut
|
||||
|
||||
$progname = $0;
|
||||
$progname =~ s,.*/,,; # use basename only
|
||||
$progname =~ s/\.\w*$//; # strip extension, if any
|
||||
|
||||
$VERSION = sprintf("%d.%02d", q$Revision: 1.33 $ =~ /(\d+)\.(\d+)/);
|
||||
|
||||
|
||||
require LWP;
|
||||
require LWP::Debug;
|
||||
require URI::URL;
|
||||
|
||||
use URI::Heuristic qw(uf_url);
|
||||
|
||||
use HTTP::Status qw(status_message);
|
||||
use HTTP::Date qw(time2str str2time);
|
||||
|
||||
|
||||
# This table lists the methods that are allowed. It should really be
|
||||
# a superset for all methods supported for every scheme that may be
|
||||
# supported by the library. Currently it might be a bit too HTTP
|
||||
# specific. You might use the -f option to force a method through.
|
||||
#
|
||||
# "" = No content in request, "C" = Needs content in request
|
||||
#
|
||||
%allowed_methods = (
|
||||
GET => "",
|
||||
HEAD => "",
|
||||
POST => "C",
|
||||
PUT => "C",
|
||||
DELETE => "",
|
||||
TRACE => "",
|
||||
OPTIONS => "",
|
||||
);
|
||||
|
||||
|
||||
# We make our own specialization of LWP::UserAgent that asks for
|
||||
# user/password if document is protected.
|
||||
{
|
||||
package RequestAgent;
|
||||
@ISA = qw(LWP::UserAgent);
|
||||
|
||||
sub new
|
||||
{
|
||||
my $self = LWP::UserAgent::new(@_);
|
||||
$self->agent("lwp-request/$main::VERSION");
|
||||
$self;
|
||||
}
|
||||
|
||||
sub get_basic_credentials
|
||||
{
|
||||
my($self, $realm, $uri) = @_;
|
||||
if ($main::opt_C) {
|
||||
return split(':', $main::opt_C, 2);
|
||||
} elsif (-t) {
|
||||
my $netloc = $uri->netloc;
|
||||
print "Enter username for $realm at $netloc: ";
|
||||
my $user = <STDIN>;
|
||||
chomp($user);
|
||||
return (undef, undef) unless length $user;
|
||||
print "Password: ";
|
||||
system("stty -echo");
|
||||
my $password = <STDIN>;
|
||||
system("stty echo");
|
||||
print "\n"; # because we disabled echo
|
||||
chomp($password);
|
||||
return ($user, $password);
|
||||
} else {
|
||||
return (undef, undef)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$method = uc(lc($progname) eq "lwp-request" ? "GET" : $progname);
|
||||
|
||||
# Parse command line
|
||||
use Getopt::Std;
|
||||
|
||||
$opt_a = undef; # content i/o in text(ascii) mode
|
||||
$opt_m = undef; # set method
|
||||
$opt_f = undef; # make request even if method is not in %allowed_methods
|
||||
$opt_b = undef; # base url
|
||||
$opt_t = undef; # timeout
|
||||
$opt_i = undef; # if-modified-since
|
||||
$opt_c = undef; # content type for POST
|
||||
$opt_C = undef; # credidentials for basic authorization
|
||||
|
||||
$opt_u = undef; # display method, URL and headers of request
|
||||
$opt_U = undef; # display request headers also
|
||||
$opt_s = undef; # display status code
|
||||
$opt_S = undef; # display whole chain of status codes
|
||||
$opt_e = undef; # display response headers (default for HEAD)
|
||||
$opt_d = undef; # don't display content
|
||||
|
||||
$opt_h = undef; # print usage
|
||||
$opt_v = undef; # print version
|
||||
|
||||
$opt_x = undef; # extra debugging info
|
||||
$opt_p = undef; # proxy URL
|
||||
$opt_P = undef; # don't load proxy setting from environment
|
||||
|
||||
$opt_o = undef; # output format
|
||||
|
||||
unless (getopts("axhvuUsSedPp:b:t:i:c:C:m:fo:")) {
|
||||
usage();
|
||||
}
|
||||
|
||||
if ($opt_v) {
|
||||
require LWP;
|
||||
my $DISTNAME = 'libwww-perl-' . LWP::Version();
|
||||
die <<"EOT";
|
||||
This is lwp-request version $VERSION ($DISTNAME)
|
||||
|
||||
Copyright 1995-1997, Gisle Aas.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the same terms as Perl itself.
|
||||
EOT
|
||||
}
|
||||
|
||||
usage() if $opt_h || !@ARGV;
|
||||
|
||||
LWP::Debug::level('+') if $opt_x;
|
||||
|
||||
# Create the user agent object
|
||||
$ua = new RequestAgent;
|
||||
|
||||
# Load proxy settings from *_proxy environment variables.
|
||||
$ua->env_proxy unless $opt_P;
|
||||
|
||||
$method = uc($opt_m) if defined $opt_m;
|
||||
|
||||
if ($opt_f) {
|
||||
if ($opt_c) {
|
||||
$allowed_methods{$method} = "C"; # force content
|
||||
} else {
|
||||
$allowed_methods{$method} = "";
|
||||
}
|
||||
} elsif (!defined $allowed_methods{$method}) {
|
||||
die "$progname: $method is not an allowed method\n";
|
||||
}
|
||||
|
||||
if ($method eq "HEAD") {
|
||||
$opt_s = 1;
|
||||
$opt_e = 1 unless $opt_d;
|
||||
$opt_d = 1;
|
||||
}
|
||||
|
||||
if (defined $opt_t) {
|
||||
$opt_t =~ /^(\d+)([smh])?/;
|
||||
die "$progname: Illegal timeout value!\n" unless defined $1;
|
||||
$timeout = $1;
|
||||
$timeout *= 60 if ($2 eq "m");
|
||||
$timeout *= 3600 if ($2 eq "h");
|
||||
$ua->timeout($timeout);
|
||||
}
|
||||
|
||||
if (defined $opt_i) {
|
||||
if (-e $opt_i) {
|
||||
$time = (stat _)[9];
|
||||
} else {
|
||||
$time = str2time($opt_i);
|
||||
die "$progname: Illegal time syntax for -i option\n"
|
||||
unless defined $time;
|
||||
}
|
||||
$opt_i = time2str($time);
|
||||
}
|
||||
|
||||
$content = undef;
|
||||
if ($allowed_methods{$method} eq "C") {
|
||||
# This request needs some content
|
||||
unless (defined $opt_c) {
|
||||
# set default content type
|
||||
$opt_c = ($method eq "POST") ?
|
||||
"application/x-www-form-urlencoded"
|
||||
: "text/plain";
|
||||
} else {
|
||||
die "$progname: Illegal Content-type format\n"
|
||||
unless $opt_c =~ m,^[\w\-]+/[\w\-]+(?:\s*;.*)?$,
|
||||
}
|
||||
print "Please enter content ($opt_c) to be ${method}ed:\n"
|
||||
if -t;
|
||||
binmode STDIN unless -t or $opt_a;
|
||||
$content = join("", <STDIN>);
|
||||
} else {
|
||||
die "$progname: Can't set Content-type for $method requests\n"
|
||||
if defined $opt_c;
|
||||
}
|
||||
|
||||
# Set up a request. We will use the same request object for all URLs.
|
||||
$request = new HTTP::Request $method;
|
||||
$request->header('If-Modified-Since', $opt_i) if defined $opt_i;
|
||||
#$request->header('Accept', '*/*');
|
||||
if ($opt_c) { # will always be set for request that wants content
|
||||
$request->header('Content-Type', $opt_c);
|
||||
$request->header('Content-Length', length $content); # Not really needed
|
||||
$request->content($content);
|
||||
}
|
||||
|
||||
|
||||
$errors = 0;
|
||||
|
||||
# Ok, now we perform the requests, one URL at a time
|
||||
while ($url = shift) {
|
||||
# Create the URL object, but protect us against bad URLs
|
||||
eval {
|
||||
if ($url =~ /^\w+:/ || $opt_b) { # is there any scheme specification
|
||||
$url = URI::URL->new($url, $opt_b);
|
||||
} else {
|
||||
$url = uf_url($url);
|
||||
}
|
||||
};
|
||||
if ($@) {
|
||||
$@ =~ s/at\s+\S+\s+line\s\d+//;
|
||||
print STDERR $@;
|
||||
$errors++;
|
||||
next;
|
||||
}
|
||||
|
||||
$ua->proxy($url->scheme, $opt_p) if $opt_p;
|
||||
|
||||
# Send the request and get a response back from the server
|
||||
$request->url($url);
|
||||
$response = $ua->request($request);
|
||||
|
||||
if ($opt_u || $opt_U) {
|
||||
my $url = $response->request->url->as_string;
|
||||
print "$method $url\n";
|
||||
print $response->request->headers_as_string, "\n" if $opt_U;
|
||||
}
|
||||
|
||||
if ($opt_S) {
|
||||
printResponseChain($response);
|
||||
} elsif ($opt_s) {
|
||||
print $response->status_line, "\n";
|
||||
}
|
||||
|
||||
if ($opt_e) {
|
||||
# Display headers
|
||||
print $response->headers_as_string;
|
||||
print "\n"; # separate headers and content
|
||||
}
|
||||
|
||||
if ($response->is_success) {
|
||||
unless ($opt_d) {
|
||||
if ($opt_o &&
|
||||
$response->content_type eq 'text/html') {
|
||||
require HTML::Parse;
|
||||
my $html = HTML::Parse::parse_html($response->content);
|
||||
{
|
||||
$opt_o eq 'ps' && do {
|
||||
require HTML::FormatPS;
|
||||
my $f = new HTML::FormatPS;
|
||||
print $f->format($html);
|
||||
last;
|
||||
};
|
||||
$opt_o eq 'text' && do {
|
||||
require HTML::FormatText;
|
||||
my $f = new HTML::FormatText;
|
||||
print $f->format($html);
|
||||
last;
|
||||
};
|
||||
$opt_o eq 'html' && do {
|
||||
print $html->as_HTML;
|
||||
last;
|
||||
};
|
||||
$opt_o eq 'links' && do {
|
||||
my $base = $response->base;
|
||||
for ( @{ $html->extract_links } ) {
|
||||
my($link, $elem) = @$_;
|
||||
my $tag = uc $elem->tag;
|
||||
$link = new URI::URL $link, $base;
|
||||
print "$tag\t", $link->abs->as_string, "\n";
|
||||
}
|
||||
last;
|
||||
};
|
||||
$opt_o eq 'dump' && do {
|
||||
$html->dump;
|
||||
last;
|
||||
};
|
||||
# It is bad to not notice this before now :-(
|
||||
die "Illegal -o option value ($opt_o)\n";
|
||||
}
|
||||
} else {
|
||||
binmode STDOUT unless $opt_a;
|
||||
print $response->content;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print STDERR $response->error_as_HTML unless $opt_d;
|
||||
$errors++;
|
||||
}
|
||||
}
|
||||
|
||||
exit $errors;
|
||||
|
||||
|
||||
sub printResponseChain
|
||||
{
|
||||
my($response) = @_;
|
||||
return unless defined $response;
|
||||
printResponseChain($response->previous);
|
||||
my $method = $response->request->method;
|
||||
my $url = $response->request->url->as_string;
|
||||
my $code = $response->code;
|
||||
print "$method $url --> ", $response->status_line, "\n";
|
||||
}
|
||||
|
||||
|
||||
sub usage
|
||||
{
|
||||
die <<"EOT";
|
||||
Usage: $progname [-options] <url>...
|
||||
-m <method> use method for the request (default is '$method')
|
||||
-f make request even if $progname believes method is illegal
|
||||
-b <base> Use the specified URL as base
|
||||
-t <timeout> Set timeout value
|
||||
-i <time> Set the If-Modified-Since header on the request
|
||||
-c <conttype> use this content-type for POST, PUT, CHECKIN
|
||||
-a Use text mode for content I/O
|
||||
-p <proxyurl> use this as a proxy
|
||||
-P don't load proxy settings from environment
|
||||
|
||||
-u Display method and URL before any response
|
||||
-U Display request headers (implies -u)
|
||||
-s Display response status code
|
||||
-S Display response status chain
|
||||
-e Display response headers
|
||||
-d Do not display content
|
||||
-o <format> Process HTML content in various ways
|
||||
|
||||
-v Show program version
|
||||
-h Print this message
|
||||
|
||||
-x Extra debugging output
|
||||
EOT
|
||||
}
|
584
tools/Perl/bin/lwp-rget
Normal file
584
tools/Perl/bin/lwp-rget
Normal file
|
@ -0,0 +1,584 @@
|
|||
#!perl -w
|
||||
|
||||
#line 18
|
||||
|
||||
=head1 NAME
|
||||
|
||||
lwp-rget - Retrieve WWW documents recursively
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
lwp-rget [--verbose] [--auth=USER:PASS] [--depth=N] [--hier] [--iis]
|
||||
[--keepext=mime/type[,mime/type]] [--limit=N] [--nospace]
|
||||
[--prefix=URL] [--sleep=N] [--tolower] <URL>
|
||||
lwp-rget --version
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This program will retrieve a document and store it in a local file. It
|
||||
will follow any links found in the document and store these documents
|
||||
as well, patching links so that they refer to these local copies.
|
||||
This process continues until there are no more unvisited links or the
|
||||
process is stopped by the one or more of the limits which can be
|
||||
controlled by the command line arguments.
|
||||
|
||||
This program is useful if you want to make a local copy of a
|
||||
collection of documents or want to do web reading off-line.
|
||||
|
||||
All documents are stored as plain files in the current directory. The
|
||||
file names chosen are derived from the last component of URL paths.
|
||||
|
||||
The options are:
|
||||
|
||||
=over 3
|
||||
|
||||
=item --auth=USER:PASS<n>
|
||||
|
||||
Set the authentication credentials to user "USER" and password "PASS" if
|
||||
any restricted parts of the web site are hit. If there are restricted
|
||||
parts of the web site and authentication credentials are not available,
|
||||
those pages will not be downloaded.
|
||||
|
||||
=item --depth=I<n>
|
||||
|
||||
Limit the recursive level. Embedded images are always loaded, even if
|
||||
they fall outside the I<--depth>. This means that one can use
|
||||
I<--depth=0> in order to fetch a single document together with all
|
||||
inline graphics.
|
||||
|
||||
The default depth is 5.
|
||||
|
||||
=item --hier
|
||||
|
||||
Download files into a hierarchy that mimics the web site structure.
|
||||
The default is to put all files in the current directory.
|
||||
|
||||
=item --iis
|
||||
|
||||
Sends an "Accept: */*" on all URL requests as a workaround for a bug in
|
||||
IIS 2.0. If no Accept MIME header is present, IIS 2.0 returns with a
|
||||
"406 No acceptable objects were found" error. Also converts any back
|
||||
slashes (\\) in URLs to forward slashes (/).
|
||||
|
||||
=item --keepext=I<mime/type[,mime/type]>
|
||||
|
||||
Keeps the current extension for the list MIME types. Useful when
|
||||
downloading text/plain documents that shouldn't all be translated to
|
||||
*.txt files.
|
||||
|
||||
=item --limit=I<n>
|
||||
|
||||
Limit the number of documents to get. The default limit is 50.
|
||||
|
||||
=item --nospace
|
||||
|
||||
Changes spaces in all URLs to underscore characters (_). Useful when
|
||||
downloading files from sites serving URLs with spaces in them. Does not
|
||||
remove spaces from fragments, e.g., "file.html#somewhere in here".
|
||||
|
||||
=item --prefix=I<url_prefix>
|
||||
|
||||
Limit the links to follow. Only URLs that start the prefix string are
|
||||
followed.
|
||||
|
||||
The default prefix is set as the "directory" of the initial URL to
|
||||
follow. For instance if we start lwp-rget with the URL
|
||||
C<http://www.sn.no/foo/bar.html>, then prefix will be set to
|
||||
C<http://www.sn.no/foo/>.
|
||||
|
||||
Use C<--prefix=''> if you don't want the fetching to be limited by any
|
||||
prefix.
|
||||
|
||||
=item --sleep=I<n>
|
||||
|
||||
Sleep I<n> seconds before retrieving each document. This options allows
|
||||
you to go slowly, not loading the server you visiting too much.
|
||||
|
||||
=item --tolower
|
||||
|
||||
Translates all links to lowercase. Useful when downloading files from
|
||||
IIS since it does not serve files in a case sensitive manner.
|
||||
|
||||
=item --verbose
|
||||
|
||||
Make more noise while running.
|
||||
|
||||
=item --quiet
|
||||
|
||||
Don't make any noise.
|
||||
|
||||
=item --version
|
||||
|
||||
Print program version number and quit.
|
||||
|
||||
=item --help
|
||||
|
||||
Print the usage message and quit.
|
||||
|
||||
=back
|
||||
|
||||
Before the program exits the name of the file, where the initial URL
|
||||
is stored, is printed on stdout. All used filenames are also printed
|
||||
on stderr as they are loaded. This printing can be suppressed with
|
||||
the I<--quiet> option.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<lwp-request>, L<LWP>
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Gisle Aas <aas@sn.no>
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
|
||||
use Getopt::Long qw(GetOptions);
|
||||
use URI::URL qw(url);
|
||||
use LWP::MediaTypes qw(media_suffix);
|
||||
|
||||
use vars qw($VERSION);
|
||||
use vars qw($MAX_DEPTH $MAX_DOCS $PREFIX $VERBOSE $QUIET $SLEEP $HIER $AUTH $IIS $TOLOWER $NOSPACE %KEEPEXT);
|
||||
|
||||
my $progname = $0;
|
||||
$progname =~ s|.*/||; # only basename left
|
||||
$progname =~ s/\.\w*$//; #strip extension if any
|
||||
|
||||
$VERSION = sprintf("%d.%02d", q$Revision: 1.16 $ =~ /(\d+)\.(\d+)/);
|
||||
|
||||
#$Getopt::Long::debug = 1;
|
||||
#$Getopt::Long::ignorecase = 0;
|
||||
|
||||
# Defaults
|
||||
$MAX_DEPTH = 5;
|
||||
$MAX_DOCS = 50;
|
||||
|
||||
GetOptions('version' => \&print_version,
|
||||
'help' => \&usage,
|
||||
'depth=i' => \$MAX_DEPTH,
|
||||
'limit=i' => \$MAX_DOCS,
|
||||
'verbose!' => \$VERBOSE,
|
||||
'quiet!' => \$QUIET,
|
||||
'sleep=i' => \$SLEEP,
|
||||
'prefix:s' => \$PREFIX,
|
||||
'hier' => \$HIER,
|
||||
'auth=s' => \$AUTH,
|
||||
'iis' => \$IIS,
|
||||
'tolower' => \$TOLOWER,
|
||||
'nospace' => \$NOSPACE,
|
||||
'keepext=s' => \$KEEPEXT{'OPT'},
|
||||
) || usage();
|
||||
|
||||
sub print_version {
|
||||
require LWP;
|
||||
my $DISTNAME = 'libwww-perl-' . LWP::Version();
|
||||
print <<"EOT";
|
||||
This is lwp-rget version $VERSION ($DISTNAME)
|
||||
|
||||
Copyright 1996-1998, Gisle Aas.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the same terms as Perl itself.
|
||||
EOT
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my $start_url = shift || usage();
|
||||
usage() if @ARGV;
|
||||
|
||||
require LWP::UserAgent;
|
||||
my $ua = new LWP::UserAgent;
|
||||
$ua->agent("$progname/$VERSION " . $ua->agent);
|
||||
$ua->env_proxy;
|
||||
|
||||
unless (defined $PREFIX) {
|
||||
$PREFIX = url($start_url); # limit to URLs below this one
|
||||
eval {
|
||||
$PREFIX->eparams(undef);
|
||||
$PREFIX->equery(undef);
|
||||
};
|
||||
|
||||
$_ = $PREFIX->epath;
|
||||
s|[^/]+$||;
|
||||
$PREFIX->epath($_);
|
||||
$PREFIX = $PREFIX->as_string;
|
||||
}
|
||||
|
||||
%KEEPEXT = map { lc($_) => 1 } split(/\s*,\s*/, $KEEPEXT{'OPT'});
|
||||
|
||||
print <<"" if $VERBOSE;
|
||||
START = $start_url
|
||||
MAX_DEPTH = $MAX_DEPTH
|
||||
MAX_DOCS = $MAX_DOCS
|
||||
PREFIX = $PREFIX
|
||||
|
||||
|
||||
my $no_docs = 0;
|
||||
my %seen = (); # mapping from URL => local_file
|
||||
|
||||
my $filename = fetch($start_url);
|
||||
print "$filename\n" unless $QUIET;
|
||||
|
||||
sub fetch
|
||||
{
|
||||
my($url, $type, $depth) = @_;
|
||||
|
||||
# Fix http://sitename.com/../blah/blah.html to
|
||||
# http://sitename.com/blah/blah.html
|
||||
$url = $url->as_string if (ref($url));
|
||||
while ($url =~ s#(https?://[^/]+/)\.\.\/#$1#) {}
|
||||
|
||||
# Fix backslashes (\) in URL if $IIS defined
|
||||
$url = fix_backslashes($url) if (defined $IIS);
|
||||
|
||||
$url = url($url) unless ref($url);
|
||||
$type ||= 'a';
|
||||
# Might be the background attribute
|
||||
$type = 'img' if ($type eq 'body' || $type eq 'td');
|
||||
$depth ||= 0;
|
||||
|
||||
# Print the URL before we start checking...
|
||||
my $out = (" " x $depth) . $url . " ";
|
||||
$out .= "." x (60 - length($out));
|
||||
print STDERR $out . " " if $VERBOSE;
|
||||
|
||||
# Can't get mailto things
|
||||
if ($url->scheme eq 'mailto') {
|
||||
print STDERR "*skipping mailto*\n" if $VERBOSE;
|
||||
return $url->as_string;
|
||||
}
|
||||
|
||||
# The $plain_url is a URL without the fragment part
|
||||
my $plain_url = $url->clone;
|
||||
$plain_url->frag(undef);
|
||||
|
||||
# Check PREFIX, but not for <IMG ...> links
|
||||
if ($type ne 'img' and $url->as_string !~ /^\Q$PREFIX/o) {
|
||||
print STDERR "*outsider*\n" if $VERBOSE;
|
||||
return $url->as_string;
|
||||
}
|
||||
|
||||
# Translate URL to lowercase if $TOLOWER defined
|
||||
$plain_url = to_lower($plain_url) if (defined $TOLOWER);
|
||||
|
||||
# If we already have it, then there is nothing to be done
|
||||
my $seen = $seen{$plain_url->as_string};
|
||||
if ($seen) {
|
||||
my $frag = $url->frag;
|
||||
$seen .= "#$frag" if defined($frag);
|
||||
$seen = protect_frag_spaces($seen);
|
||||
print STDERR "$seen (again)\n" if $VERBOSE;
|
||||
return $seen;
|
||||
}
|
||||
|
||||
# Too much or too deep
|
||||
if ($depth > $MAX_DEPTH and $type ne 'img') {
|
||||
print STDERR "*too deep*\n" if $VERBOSE;
|
||||
return $url;
|
||||
}
|
||||
if ($no_docs > $MAX_DOCS) {
|
||||
print STDERR "*too many*\n" if $VERBOSE;
|
||||
return $url;
|
||||
}
|
||||
|
||||
# Fetch document
|
||||
$no_docs++;
|
||||
sleep($SLEEP) if $SLEEP;
|
||||
my $req = HTTP::Request->new(GET => $url);
|
||||
# See: http://ftp.sunet.se/pub/NT/mirror-microsoft/kb/Q163/7/74.TXT
|
||||
$req->header ('Accept', '*/*') if (defined $IIS); # GIF/JPG from IIS 2.0
|
||||
$req->authorization_basic(split (/:/, $AUTH)) if (defined $AUTH);
|
||||
my $res = $ua->request($req);
|
||||
|
||||
# Check outcome
|
||||
if ($res->is_success) {
|
||||
my $doc = $res->content;
|
||||
my $ct = $res->content_type;
|
||||
my $name = find_name($res->request->url, $ct);
|
||||
print STDERR "$name\n" unless $QUIET;
|
||||
$seen{$plain_url->as_string} = $name;
|
||||
|
||||
# If the file is HTML, then we look for internal links
|
||||
if ($ct eq "text/html") {
|
||||
# Save an unprosessed version of the HTML document. This
|
||||
# both reserves the name used, and it also ensures that we
|
||||
# don't loose everything if this program is killed before
|
||||
# we finish.
|
||||
save($name, $doc);
|
||||
my $base = $res->base;
|
||||
|
||||
# Follow and substitute links...
|
||||
$doc =~
|
||||
s/
|
||||
(
|
||||
<(img|a|body|area|frame|td)\b # some interesting tag
|
||||
[^>]+ # still inside tag (not strictly correct)
|
||||
\b(?:src|href|background) # some link attribute
|
||||
\s*=\s* # =
|
||||
)
|
||||
(?: # scope of OR-ing
|
||||
(")([^"]*)" | # value in double quotes OR
|
||||
(')([^']*)' | # value in single quotes OR
|
||||
([^\s>]+) # quoteless value
|
||||
)
|
||||
/
|
||||
new_link($1, lc($2), $3||$5, $4||$6||$7, $base, $name, $depth+1)
|
||||
/giex;
|
||||
# XXX
|
||||
# The regular expression above is not strictly correct.
|
||||
# It is not really possible to parse HTML with a single
|
||||
# regular expression, but it is faster. Tags that might
|
||||
# confuse us include:
|
||||
# <a alt="href" href=link.html>
|
||||
# <a alt=">" href="link.html">
|
||||
#
|
||||
}
|
||||
save($name, $doc);
|
||||
return $name;
|
||||
} else {
|
||||
print STDERR $res->code . " " . $res->message . "\n" if $VERBOSE;
|
||||
$seen{$plain_url->as_string} = $url->as_string;
|
||||
return $url->as_string;
|
||||
}
|
||||
}
|
||||
|
||||
sub new_link
|
||||
{
|
||||
my($pre, $type, $quote, $url, $base, $localbase, $depth) = @_;
|
||||
|
||||
$url = protect_frag_spaces($url);
|
||||
|
||||
$url = fetch(url($url, $base)->abs, $type, $depth);
|
||||
$url = url("file:$url", "file:$localbase")->rel
|
||||
unless $url =~ /^[.+\-\w]+:/;
|
||||
|
||||
$url = unprotect_frag_spaces($url);
|
||||
|
||||
return $pre . $quote . $url . $quote;
|
||||
}
|
||||
|
||||
|
||||
sub protect_frag_spaces
|
||||
{
|
||||
my ($url) = @_;
|
||||
|
||||
$url = $url->as_string if (ref($url));
|
||||
|
||||
if ($url =~ m/^([^#]*#)(.+)$/)
|
||||
{
|
||||
my ($base, $frag) = ($1, $2);
|
||||
$frag =~ s/ /%20/g;
|
||||
$url = $base . $frag;
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
||||
sub unprotect_frag_spaces
|
||||
{
|
||||
my ($url) = @_;
|
||||
|
||||
$url = $url->as_string if (ref($url));
|
||||
|
||||
if ($url =~ m/^([^#]*#)(.+)$/)
|
||||
{
|
||||
my ($base, $frag) = ($1, $2);
|
||||
$frag =~ s/%20/ /g;
|
||||
$url = $base . $frag;
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
||||
sub fix_backslashes
|
||||
{
|
||||
my ($url) = @_;
|
||||
my ($base, $frag);
|
||||
|
||||
$url = $url->as_string if (ref($url));
|
||||
|
||||
if ($url =~ m/([^#]+)(#.*)/)
|
||||
{
|
||||
($base, $frag) = ($1, $2);
|
||||
}
|
||||
else
|
||||
{
|
||||
$base = $url;
|
||||
$frag = "";
|
||||
}
|
||||
|
||||
$base =~ tr/\\/\//;
|
||||
$base =~ s/%5[cC]/\//g; # URL-encoded back slash is %5C
|
||||
|
||||
return $base . $frag;
|
||||
}
|
||||
|
||||
|
||||
sub to_lower
|
||||
{
|
||||
my ($url) = @_;
|
||||
my $was_object = 0;
|
||||
|
||||
if (ref($url))
|
||||
{
|
||||
$url = $url->as_string;
|
||||
$was_object = 1;
|
||||
}
|
||||
|
||||
if ($url =~ m/([^#]+)(#.*)/)
|
||||
{
|
||||
$url = lc($1) . $2;
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = lc($url);
|
||||
}
|
||||
|
||||
if ($was_object == 1)
|
||||
{
|
||||
return url($url);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub translate_spaces
|
||||
{
|
||||
my ($url) = @_;
|
||||
my ($base, $frag);
|
||||
|
||||
$url = $url->as_string if (ref($url));
|
||||
|
||||
if ($url =~ m/([^#]+)(#.*)/)
|
||||
{
|
||||
($base, $frag) = ($1, $2);
|
||||
}
|
||||
else
|
||||
{
|
||||
$base = $url;
|
||||
$frag = "";
|
||||
}
|
||||
|
||||
$base =~ s/^ *//; # Remove initial spaces from base
|
||||
$base =~ s/ *$//; # Remove trailing spaces from base
|
||||
|
||||
$base =~ tr/ /_/;
|
||||
$base =~ s/%20/_/g; # URL-encoded space is %20
|
||||
|
||||
return $base . $frag;
|
||||
}
|
||||
|
||||
|
||||
sub mkdirp
|
||||
{
|
||||
my($directory, $mode) = @_;
|
||||
my @dirs = split(/\//, $directory);
|
||||
my $path = shift(@dirs); # build it as we go
|
||||
my $result = 1; # assume it will work
|
||||
|
||||
unless (-d $path) {
|
||||
$result &&= mkdir($path, $mode);
|
||||
}
|
||||
|
||||
foreach (@dirs) {
|
||||
$path .= "/$_";
|
||||
if ( ! -d $path) {
|
||||
$result &&= mkdir($path, $mode);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
sub find_name
|
||||
{
|
||||
my($url, $type) = @_;
|
||||
#print "find_name($url, $type)\n";
|
||||
|
||||
# Translate spaces in URL to underscores (_) if $NOSPACE defined
|
||||
$url = translate_spaces($url) if (defined $NOSPACE);
|
||||
|
||||
# Translate URL to lowercase if $TOLOWER defined
|
||||
$url = to_lower($url) if (defined $TOLOWER);
|
||||
|
||||
$url = url($url) unless ref($url);
|
||||
|
||||
my $path = $url->path;
|
||||
|
||||
# trim path until only the basename is left
|
||||
$path =~ s|(.*/)||;
|
||||
my $dirname = ".$1";
|
||||
if (!$HIER) {
|
||||
$dirname = "";
|
||||
} elsif (! -d $dirname) {
|
||||
mkdirp($dirname, 0775);
|
||||
}
|
||||
|
||||
my $extra = ""; # something to make the name unique
|
||||
my $suffix;
|
||||
|
||||
if ($KEEPEXT{lc($type)}) {
|
||||
$suffix = ($path =~ m/\.(.*)/) ? $1 : "";
|
||||
} else {
|
||||
$suffix = media_suffix($type);
|
||||
}
|
||||
|
||||
$path =~ s|\..*||; # trim suffix
|
||||
$path = "index" unless length $path;
|
||||
|
||||
while (1) {
|
||||
# Construct a new file name
|
||||
my $file = $dirname . $path . $extra;
|
||||
$file .= ".$suffix" if $suffix;
|
||||
# Check if it is unique
|
||||
return $file unless -f $file;
|
||||
|
||||
# Try something extra
|
||||
unless ($extra) {
|
||||
$extra = "001";
|
||||
next;
|
||||
}
|
||||
$extra++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub save
|
||||
{
|
||||
my $name = shift;
|
||||
#print "save($name,...)\n";
|
||||
open(FILE, ">$name") || die "Can't save $name: $!";
|
||||
binmode FILE;
|
||||
print FILE $_[0];
|
||||
close(FILE);
|
||||
}
|
||||
|
||||
|
||||
sub usage
|
||||
{
|
||||
die <<"";
|
||||
Usage: $progname [options] <URL>
|
||||
Allowed options are:
|
||||
--auth=USER:PASS Set authentication credentials for web site
|
||||
--depth=N Maximum depth to traverse (default is $MAX_DEPTH)
|
||||
--hier Download into hierarchy (not all files into cwd)
|
||||
--iis Workaround IIS 2.0 bug by sending "Accept: */*" MIME
|
||||
header; translates backslashes (\\) to forward slashes (/)
|
||||
--keepext=type Keep file extension for MIME types (comma-separated list)
|
||||
--limit=N A limit on the number documents to get (default is $MAX_DOCS)
|
||||
--nospace Translate spaces URLs (not #fragments) to underscores (_)
|
||||
--version Print version number and quit
|
||||
--verbose More output
|
||||
--quiet No output
|
||||
--sleep=SECS Sleep between gets, ie. go slowly
|
||||
--prefix=PREFIX Limit URLs to follow to those which begin with PREFIX
|
||||
--tolower Translate all URLs to lowercase (useful with IIS servers)
|
||||
|
||||
}
|
17
tools/Perl/bin/p_uninst.dat
Normal file
17
tools/Perl/bin/p_uninst.dat
Normal file
|
@ -0,0 +1,17 @@
|
|||
$app_name = 'ActivePerl';
|
||||
$is_uninstall_string = 'C:\\WINNT\\uninst.exe -fC:\\Perl\\DeIsL1.isu';
|
||||
$path_info = [
|
||||
'C:\\Perl\\bin'
|
||||
];
|
||||
$iis_virt_dir = [];
|
||||
$iis_script_map = {};
|
||||
$ns_config_dir = undef;
|
||||
$lines_in_file = {};
|
||||
$directory = [
|
||||
'C:\\Perl\\html\\lib'
|
||||
];
|
||||
$file = [
|
||||
'C:\\Perl\\bin\\ppm.bat',
|
||||
'C:\\Perl\\bin\\perlse.pl',
|
||||
'C:\\Perl\\bin/p_uninst.dat'
|
||||
];
|
BIN
tools/Perl/bin/perl.exe
Normal file
BIN
tools/Perl/bin/perl.exe
Normal file
Binary file not shown.
BIN
tools/Perl/bin/perl5.00502.exe
Normal file
BIN
tools/Perl/bin/perl5.00502.exe
Normal file
Binary file not shown.
BIN
tools/Perl/bin/perlcore.dll
Normal file
BIN
tools/Perl/bin/perlcore.dll
Normal file
Binary file not shown.
BIN
tools/Perl/bin/perlglob.exe
Normal file
BIN
tools/Perl/bin/perlglob.exe
Normal file
Binary file not shown.
1108
tools/Perl/bin/ppm.pl
Normal file
1108
tools/Perl/bin/ppm.pl
Normal file
File diff suppressed because it is too large
Load diff
211
tools/Perl/bin/uninstall.pl
Normal file
211
tools/Perl/bin/uninstall.pl
Normal file
|
@ -0,0 +1,211 @@
|
|||
#
|
||||
# Uninstall.pl
|
||||
#
|
||||
# Author: Michael Smith (mikes@ActiveState.com)
|
||||
#
|
||||
# Copyright © 1998 ActiveState Tool Corp., all rights reserved.
|
||||
#
|
||||
###########################################################
|
||||
|
||||
use Win32::Registry;
|
||||
use File::Find;
|
||||
use MetabaseConfig;
|
||||
|
||||
my $data_file = $ARGV[0];
|
||||
my $ENVIRONMENT_KEY = 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
|
||||
|
||||
ReadData();
|
||||
Warn();
|
||||
UninstallDependents();
|
||||
CleanPath();
|
||||
RemoveIISVirtDirs();
|
||||
RemoveIISScriptMaps();
|
||||
RemoveLinesFromFiles();
|
||||
RemoveDirectories();
|
||||
RemoveFiles();
|
||||
CallInstallShield();
|
||||
sleep(3);
|
||||
exit(0);
|
||||
|
||||
sub ReadData {
|
||||
print "Reading uninstall data...\n";
|
||||
my $data = '';
|
||||
$rv = open(DATA, "<$data_file");
|
||||
if($rv) {
|
||||
map($data .= $_, <DATA>);
|
||||
close(DATA);
|
||||
eval($data);
|
||||
}else{
|
||||
die "Error reading uninstallation data file. Aborting!!";
|
||||
}
|
||||
}
|
||||
|
||||
sub Warn {
|
||||
print "This will uninstall $app_name. Do you wish to continue?\n";
|
||||
print "[y|N] ==>";
|
||||
my $response = '';
|
||||
while(($response = <STDIN>) !~ /^[\nyn]/i){};
|
||||
if($response !~ /^y/i) {
|
||||
print "Aborting $app_name uninstallation!\n";
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
sub UninstallDependents {
|
||||
my $RegObj = 0;
|
||||
my $UninstallString = '';
|
||||
my $type = 0;
|
||||
my $rv = 0;
|
||||
|
||||
foreach $dependent (@$dependents) {
|
||||
print "$dependent is dependent on $app_name\n" .
|
||||
"and will not function correctly without it.\n" .
|
||||
"Would you like to uninstall $dependent?\n" .
|
||||
"[y|n] ==>";
|
||||
while(($response = <STDIN>) !~ /[yn]/i){};
|
||||
|
||||
if($response =~ /y/i) {
|
||||
$rv = $HKEY_LOCAL_MACHINE->Open("software\\microsoft\\windows\\currentversion\\uninstall\\$dependent", $RegObj);
|
||||
if($rv) {
|
||||
$rv = $RegObj->QueryValueEx("UninstallString", $type, $UninstallString);
|
||||
if($rv) {
|
||||
$RegObj->Close();
|
||||
print $UninstallString;
|
||||
print "Uninstalling $dependent...\n";
|
||||
$rv = (system($UninstallString) ? 0 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
if(!$rv) {
|
||||
print "Error uninstalling $dependent!\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub CleanPath {
|
||||
if(@$path_info) {
|
||||
print "Cleaning PATH...\n";
|
||||
my $path = '';
|
||||
if(Win32::IsWinNT) {
|
||||
my $Environment = 0;
|
||||
if($HKEY_LOCAL_MACHINE->Open($ENVIRONMENT_KEY, $Environment)) {
|
||||
if($Environment->QueryValueEx("PATH", $type, $path)) {
|
||||
for $dir (@$path_info) {
|
||||
$dir =~ s/\\/\\\\/g;
|
||||
$path =~ s/$dir;?//ig;
|
||||
}
|
||||
$Environment->SetValueEx("PATH", -1, $type, $path);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
my $file = "$ENV{'SystemDrive'}/autoexec.bat";
|
||||
if(open(FILE, "<$file")) {
|
||||
my @statements = <FILE>;
|
||||
close(FILE);
|
||||
my $path = '';
|
||||
for $statement (@statements) {
|
||||
if($statement =~ /\s+path\s?=/i) {
|
||||
$path = $statement;
|
||||
for $dir (@$path_info) {
|
||||
$dir =~ s/\\/\\\\/g;
|
||||
$path =~ s/$dir;?//ig;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(open(FILE, ">$file")) {
|
||||
print FILE @statements;
|
||||
close(FILE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub RemoveIISVirtDirs {
|
||||
if(@$iis_virt_dir) {
|
||||
print "Removing IIS4 virtual directories...\n";
|
||||
for $virt_dir (@$iis_virt_dir) {
|
||||
$rv = MetabaseConfig::DeleteVirDir(1, $virt_dir);
|
||||
if($rv =~ /^Error/i){
|
||||
print "$rv\n";
|
||||
system('pause');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub RemoveIISScriptMaps {
|
||||
if(keys %$iis_script_map) {
|
||||
print "Removing IIS4 script maps...\n";
|
||||
my $virt_dir = '';
|
||||
for $key (keys %$iis_script_map) {
|
||||
print "Virtual Directory ==> $key\n";
|
||||
for $script_map (@{$iis_script_map->{$key}}) {
|
||||
print "\t$key ==> $script_map\n";
|
||||
$virt_dir = $key;
|
||||
$virt_dir = ($virt_dir eq '.' ? '' : $virt_dir);
|
||||
$rv = MetabaseConfig::RemoveFileExtMapping(1, $virt_dir, $script_map);
|
||||
if($rv =~ /^Error/i){
|
||||
print "$rv\n";
|
||||
system('pause');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub RemoveLinesFromFiles {
|
||||
my $file;
|
||||
|
||||
foreach $file (keys %$lines_in_file) {
|
||||
open(FILE, "<$file") or next;
|
||||
my @lines = <FILE>;
|
||||
close(FILE);
|
||||
open(FILE, ">$file") or next;
|
||||
LINE: foreach $line (@lines) {
|
||||
chomp $line;
|
||||
for ($offset = 0; $offset <= $#{$$lines_in_file{$file}}; $offset++) {
|
||||
if ($line eq $$lines_in_file{$file}[$offset]) {
|
||||
splice(@{$$lines_in_file{$file}}, $offset, 1);
|
||||
next LINE;
|
||||
}
|
||||
}
|
||||
print FILE "$line\n";
|
||||
}
|
||||
close(FILE);
|
||||
}
|
||||
}
|
||||
|
||||
sub RemoveDirectories {
|
||||
if(@$directory) {
|
||||
print "Removing directories...\n";
|
||||
for $dir (@$directory) {
|
||||
finddepth(\&DeleteFiles, $dir);
|
||||
rmdir($dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub RemoveFiles {
|
||||
if(@$file) {
|
||||
print "Removing files...\n";
|
||||
for $file (@$file) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub CallInstallShield {
|
||||
print "Calling InstallShield...\n";
|
||||
system("start $is_uninstall_string");
|
||||
}
|
||||
|
||||
sub DeleteFiles {
|
||||
if(-d $File::Find::name) {
|
||||
rmdir("$File::Find::name");
|
||||
} else {
|
||||
unlink("$File::Find::name");
|
||||
}
|
||||
}
|
||||
|
120
tools/Perl/pl/REP.PL
Normal file
120
tools/Perl/pl/REP.PL
Normal file
|
@ -0,0 +1,120 @@
|
|||
# main
|
||||
#{
|
||||
($ReportFile,$OldFile)=@ARGV;
|
||||
|
||||
if ($OldFile ne "")
|
||||
{
|
||||
ReadOldFile($OldFile);
|
||||
}
|
||||
|
||||
&FindStuff($ReportFile);
|
||||
#}
|
||||
|
||||
sub ReadOldFile
|
||||
{
|
||||
local ($INFILE)=@_;
|
||||
|
||||
open(INFILE) || die "Can't open in file $INFILE; $!";
|
||||
|
||||
while (<INFILE>)
|
||||
{
|
||||
chop $_;
|
||||
next if ($_ eq "");
|
||||
|
||||
if (/^Reporting Section (\w+)\s/)
|
||||
{
|
||||
local($Section)=$1;
|
||||
|
||||
while (<INFILE>)
|
||||
{
|
||||
chop $_;
|
||||
last if ($_ eq "");
|
||||
if (/^(\w+)\s+(\d+)/)
|
||||
{
|
||||
local ($FileName)=$1;
|
||||
local ($Size)=$2;
|
||||
local ($SecFile)="$Section:$FileName";
|
||||
|
||||
$OldSecFileToSize{$SecFile}=$2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
die "Expection section got $_";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub FindStuff
|
||||
{
|
||||
local ($INFILE)=@_;
|
||||
|
||||
open(INFILE) || die "Can't open in file $INFILE; $!";
|
||||
|
||||
while (<INFILE>)
|
||||
{
|
||||
chop $_;
|
||||
last if (/^Program/);
|
||||
|
||||
if (/^\s[A-Z0-9]+\s[A-Z0-9]+\s([A-Z0-9]+)\s[A-Z0-9]+\s(\w+)+\s+\.(\w+)_.*/)
|
||||
{
|
||||
$Size=$1;
|
||||
$Section=$2;
|
||||
$File=$3;
|
||||
|
||||
push (@AllSecs,$Section) if (!$SecSeen{$Section}++);
|
||||
|
||||
$SecToRec{$Section}.="!" if ($SecToRec{$Section} ne "");
|
||||
$SecToRec{$Section}.="$File:$Size";
|
||||
}
|
||||
}
|
||||
|
||||
close(INFILE);
|
||||
|
||||
foreach $Sec (@AllSecs)
|
||||
{
|
||||
local(@Recs)=split(/!/,$SecToRec{$Sec});
|
||||
local(%SizeToFile);
|
||||
|
||||
local ($SizeInAll)=0;
|
||||
|
||||
foreach $DatRec (@Recs)
|
||||
{
|
||||
($File,$Size)= split(/:/,$DatRec);
|
||||
$Size=hex($Size);
|
||||
|
||||
$SizeInAll+=$Size;
|
||||
|
||||
$SizeToFile{$Size}.=":" if ($SizeToFile{$Size} ne "");
|
||||
$SizeToFile{$Size}.=$File;
|
||||
}
|
||||
|
||||
$SizeK=$SizeInAll/1024;
|
||||
|
||||
print "\nReporting Section $Sec ($SizeK $SizeInAll)\n";
|
||||
|
||||
foreach $Num (sort numerically keys(%SizeToFile))
|
||||
{
|
||||
local(@Files)=split(/:/,$SizeToFile{$Num});
|
||||
|
||||
foreach $LastFile (@Files)
|
||||
{
|
||||
print "$LastFile\t$Num";
|
||||
local($SecFile)="$Sec:$LastFile";
|
||||
|
||||
if ($OldSecFileToSize{$SecFile})
|
||||
{
|
||||
local($Changed)=$Num-$OldSecFileToSize{$SecFile};
|
||||
print"\t$Changed";
|
||||
# print"was $OldSecFileToSize{$SecFile}";
|
||||
}
|
||||
|
||||
print "\n";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub numerically { $b <=> $a;}
|
94
tools/Perl/pl/anim.pl
Normal file
94
tools/Perl/pl/anim.pl
Normal file
|
@ -0,0 +1,94 @@
|
|||
LettersAndNames=
|
||||
(
|
||||
"A","ANGRY",
|
||||
"B","BORED",
|
||||
"C","CHEER",
|
||||
"F","FIGHT",
|
||||
"H","THROW",
|
||||
"I","ITCH",
|
||||
"K","CRY",
|
||||
"L","LOOPLEASE",
|
||||
"N","SLIDE",
|
||||
"O","DEAD",
|
||||
"R","RUN",
|
||||
"S","STAND",
|
||||
"T","TUMBLE",
|
||||
# "U","WATING",
|
||||
"V","VOMIT",
|
||||
"W","WALK",
|
||||
"Y","YARN",
|
||||
);
|
||||
|
||||
foreach $Val (keys %LettersAndNames)
|
||||
{
|
||||
push (@Letters,$Val);
|
||||
}
|
||||
|
||||
while (<>)
|
||||
{
|
||||
foreach $Letter (@Letters)
|
||||
{
|
||||
if (/(FRM_CH\d$Letter\d+)/)
|
||||
{
|
||||
$AllFrames{$Letter}.=":$1";
|
||||
}
|
||||
}
|
||||
}
|
||||
print ("/* Generated by anim.pl, so please don't go hand editing this file like some sort of cunt. xxxx gaz. */ \n");
|
||||
|
||||
print ("#include \"data\\graf\\kid.h\"\n");
|
||||
print ("#include \"gfx\\anim.h\"\n\n");
|
||||
|
||||
foreach $Letter (@Letters)
|
||||
{
|
||||
@ThisLettersFrames=split(/:/,$AllFrames{$Letter});
|
||||
|
||||
$LargestFrame=0;
|
||||
|
||||
foreach $Frame (@ThisLettersFrames)
|
||||
{
|
||||
$Frame=~/FRM_CH\d$Letter(\d+)/;
|
||||
$LargestFrame=$1 if ($1 > $LargestFrame);
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
$LargestFrame=sprintf("%d",$LargestFrame);
|
||||
$NumOfFrames=$LargestFrame+1;
|
||||
|
||||
for ($f=1;$f<6;$f++)
|
||||
{
|
||||
printf("static u16 const ANM_$LettersAndNames{$Letter}$f\[$NumOfFrames\]={",);
|
||||
|
||||
for ($i=0;$i<$NumOfFrames;$i++)
|
||||
{
|
||||
$Str=sprintf("FRM_CH$f$Letter%04d,",$i);
|
||||
print $Str;
|
||||
}
|
||||
|
||||
print "};\n";
|
||||
}
|
||||
print("\nstatic ANM const ANM_$LettersAndNames{$Letter}={");
|
||||
print ("$NumOfFrames,");
|
||||
print ("{");
|
||||
|
||||
for ($f=1;$f<6;$f++)
|
||||
{
|
||||
print "ANM_$LettersAndNames{$Letter}$f,";
|
||||
}
|
||||
print ("}};\n\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
print "ANM const * const AnimTab[]=\n{\n";
|
||||
|
||||
foreach $Letter (@Letters)
|
||||
{
|
||||
print "\t&ANM_$LettersAndNames{$Letter},\n";
|
||||
|
||||
}
|
||||
|
||||
print "};\n";
|
||||
|
||||
|
||||
|
37
tools/Perl/pl/check.pl
Normal file
37
tools/Perl/pl/check.pl
Normal file
|
@ -0,0 +1,37 @@
|
|||
$HadOver=0;
|
||||
|
||||
while (<>)
|
||||
{
|
||||
chop $_;
|
||||
$File=$_;
|
||||
|
||||
if ($File ne "")
|
||||
{
|
||||
local($INFILE)=$File;
|
||||
binmode($INFILE);
|
||||
|
||||
open(INFILE) || die "Can't open in file $INFILE; $!";
|
||||
binmode INFILE;
|
||||
$Size= -s INFILE;
|
||||
|
||||
$buf='';
|
||||
read(INFILE,$buf,$Size);
|
||||
|
||||
if ($buf=~/_GLOBAL_\.[ID]/)
|
||||
{
|
||||
print "Construction code in $File\n";
|
||||
$HadOver=1;
|
||||
}
|
||||
|
||||
close(INFILE);
|
||||
}
|
||||
}
|
||||
|
||||
if ($HadOver == 0)
|
||||
{
|
||||
print "No errors";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Error: Constructors in overlay code";
|
||||
}
|
97
tools/Perl/pl/checkdat.pl
Normal file
97
tools/Perl/pl/checkdat.pl
Normal file
|
@ -0,0 +1,97 @@
|
|||
$Errors=0;
|
||||
|
||||
while (<>)
|
||||
{
|
||||
/^\[(.*)\]/;
|
||||
|
||||
if ($1 ne "")
|
||||
{
|
||||
local (@Text);
|
||||
local ($StrId)=($1);
|
||||
|
||||
$Text[0]=GetLang("Eng");
|
||||
$Text[1]=GetLang("Fre");
|
||||
$Text[2]=GetLang("Ger");
|
||||
$Text[3]=GetLang("Swe");
|
||||
$Text[5]=GetLang("Jap");
|
||||
|
||||
$Errors+=CheckPerc($StrId,@Text);
|
||||
}
|
||||
}
|
||||
|
||||
if ($Errors != 0)
|
||||
{
|
||||
print "Some monkey's messed up the dbase with $Errors errors";
|
||||
}
|
||||
|
||||
sub GetLang
|
||||
{
|
||||
local ($LangStr)=@_;
|
||||
|
||||
$_=<>;
|
||||
die if (!(/($LangStr=\".*\")/));
|
||||
("File $ARGV line $. : $1");
|
||||
}
|
||||
|
||||
|
||||
sub CheckPerc
|
||||
{
|
||||
local ($StrId,@Text)=@_;
|
||||
local ($f);
|
||||
local ($Errors);
|
||||
|
||||
@Master=MakePercArray($Text[0]);
|
||||
|
||||
for ($f=1;$f<6;$f++)
|
||||
{
|
||||
local (@Local)=MakePercArray($Text[$f]);
|
||||
|
||||
if (!CheckPercArray(@Local))
|
||||
{
|
||||
print "Error with $StrId\n";
|
||||
$Text[0]=~/^File .* line .* : (.*)/;
|
||||
local ($ShouldBe)=$1;
|
||||
print "Should be $ShouldBe\n";
|
||||
print "$Text[$f]\n\n";
|
||||
$Errors++;
|
||||
}
|
||||
}
|
||||
return($Errors);
|
||||
}
|
||||
|
||||
sub CheckPercArray
|
||||
{
|
||||
local(@Local)=@_;
|
||||
local ($f);
|
||||
|
||||
for ($f=0;$f<@Local;$f++)
|
||||
{
|
||||
return(0) if ($Local[$f] ne $Master[$f])
|
||||
}
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
sub MakePercArray
|
||||
{
|
||||
local ($Str)=@_;
|
||||
local (@Ret);
|
||||
|
||||
$Str=~s/%%/!!/g;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if ($Str=~/%([A-Za-z0-9+-]*)/)
|
||||
{
|
||||
push (@Ret,$1);
|
||||
$Str=$';
|
||||
}
|
||||
else
|
||||
{
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
return(@Ret);
|
||||
|
||||
}
|
18
tools/Perl/pl/dep.pl
Normal file
18
tools/Perl/pl/dep.pl
Normal file
|
@ -0,0 +1,18 @@
|
|||
# main
|
||||
#{
|
||||
($InFile,$OutFile,$ObjFile)=@ARGV;
|
||||
|
||||
$OutFile=">$OutFile";
|
||||
|
||||
open(InFile) || die "Can't open in file $InFile; $!";
|
||||
open(OutFile) || die "Can't open in file $OutFile; $!";
|
||||
|
||||
while (<InFile>)
|
||||
{
|
||||
s/^.*\.obj.*:\w*.*\.cpp/$ObjFile:/g;
|
||||
print (OutFile $_);
|
||||
}
|
||||
|
||||
close(OutFile);
|
||||
close(InFile);
|
||||
#}
|
60
tools/Perl/pl/features.pl
Normal file
60
tools/Perl/pl/features.pl
Normal file
|
@ -0,0 +1,60 @@
|
|||
$OutFile=shift(@ARGV);
|
||||
$World=shift(@ARGV);
|
||||
$Type=shift(@ARGV);
|
||||
$Command=shift(@ARGV);
|
||||
$DataOut=shift(@ARGV);
|
||||
$GrafDir=shift(@ARGV);
|
||||
|
||||
$OutFile=">$OutFile";
|
||||
|
||||
open(OutFile) || die "Can't open in file $OutFile; $!";
|
||||
|
||||
printf(OutFile ".PHONY : $World$Type clean$World$Type\n\n");
|
||||
|
||||
foreach $Val (@ARGV)
|
||||
{
|
||||
@Stuff=split(/-/,$Val);
|
||||
$ArsName=shift(@Stuff);
|
||||
|
||||
push(@ArsNames,$ArsName);
|
||||
|
||||
$ArsNameToAnims{$ArsName}=join('!',@Stuff);
|
||||
}
|
||||
|
||||
printf(OutFile "$World$Type");
|
||||
printf(OutFile "_ARS_FILES := ");
|
||||
|
||||
foreach $Ars (@ArsNames)
|
||||
{printf(OutFile "$DataOut$Ars.ars ");}
|
||||
|
||||
printf(OutFile "\n");
|
||||
|
||||
foreach $Ars (@ArsNames)
|
||||
{
|
||||
printf(OutFile "$DataOut$Ars.ars : ");
|
||||
|
||||
@Anims=split(/!/,$ArsNameToAnims{$Ars});
|
||||
|
||||
foreach $Anim (@Anims)
|
||||
{printf(OutFile "$GrafDir$Ars/$Anim.gin ");}
|
||||
|
||||
printf(OutFile "\n\t$Command ");
|
||||
|
||||
foreach $Anim (@Anims)
|
||||
{printf(OutFile "$GrafDir$Ars/$Anim.gin ");}
|
||||
|
||||
printf(OutFile "\n\n");
|
||||
}
|
||||
|
||||
printf(OutFile "$World$Type : \$($World$Type");
|
||||
printf(OutFile "_ARS_FILES)\n\n");
|
||||
|
||||
printf(OutFile "clean$World$Type :\n");
|
||||
printf(OutFile "\t\@\$(RM) -f \$($World$Type");
|
||||
printf(OutFile "_ARS_FILES)\n");
|
||||
printf(OutFile "\t\@\$(ECHO) Cleaned $World $Type\n");
|
||||
|
||||
close(OutFile);
|
||||
|
||||
|
||||
|
204
tools/Perl/pl/gfxmak.pl
Normal file
204
tools/Perl/pl/gfxmak.pl
Normal file
|
@ -0,0 +1,204 @@
|
|||
|
||||
$OutFile=shift(@ARGV);
|
||||
$World=shift(@ARGV);
|
||||
$DataOut=shift(@ARGV);
|
||||
$GrafDir=shift(@ARGV);
|
||||
|
||||
if (0)
|
||||
{
|
||||
printf "OutFile : $OutFile\n";
|
||||
printf "World : $World\n";
|
||||
printf "DataOut : $DataOut\n";
|
||||
printf "GrafDir : $GrafDir\n";
|
||||
printf "\n";
|
||||
}
|
||||
|
||||
$OutFile=">$OutFile";
|
||||
|
||||
open(OutFile) || die "Can't open in file $OutFile; $!";
|
||||
|
||||
$RidesDir=$GrafDir;
|
||||
|
||||
$RidesOutDir=$DataOut;
|
||||
|
||||
foreach $Val (@ARGV)
|
||||
{
|
||||
@Stuff=split(/-/,$Val);
|
||||
|
||||
$RideBank=shift(@Stuff);
|
||||
|
||||
$RideName=shift(@Stuff);
|
||||
|
||||
if ($RideBank eq 1)
|
||||
{
|
||||
push(@RideNamesBank1,$RideName);
|
||||
}
|
||||
|
||||
if ($RideBank eq 2)
|
||||
{
|
||||
push(@RideNamesBank2,$RideName);
|
||||
}
|
||||
|
||||
|
||||
push(@RideNames,$RideName);
|
||||
|
||||
$RideNameToAnims{$RideName}=join('!',@Stuff);
|
||||
$RideNameToRideBank{$RideName}=$RideBank;
|
||||
}
|
||||
|
||||
foreach $Ride (@RideNames)
|
||||
{push (@AllArsFiles,"$RidesOutDir$Ride.ars");}
|
||||
|
||||
$SharedOutWorld_1 ="shared_out_";
|
||||
$SharedOutWorld_1 .="$World";
|
||||
$SharedOutWorld_1 .="_1";
|
||||
|
||||
|
||||
$SharedOutWorld_2 ="shared_out_";
|
||||
$SharedOutWorld_2 .="$World";
|
||||
$SharedOutWorld_2 .="_2";
|
||||
|
||||
print (OutFile ".PHONY : make$World clean$World shared$World shared$World");
|
||||
print (OutFile "1 shared$World");
|
||||
print (OutFile "2 cleanshared$World\n\n");
|
||||
|
||||
printf(OutFile "shared_out_$World := \$(REPORT_DIR)/$World.rep\n");
|
||||
|
||||
printf (OutFile "$SharedOutWorld_1 := \$(REPORT_DIR)/$World");
|
||||
printf (OutFile "_1.rep\n");
|
||||
|
||||
printf (OutFile "$SharedOutWorld_2 := \$(REPORT_DIR)/$World");
|
||||
printf (OutFile "_2.rep\n");
|
||||
|
||||
printf (OutFile "\n\n");
|
||||
|
||||
print (OutFile $World,"_ARS_FILES := ",join(' ',@AllArsFiles),"\n\n");
|
||||
|
||||
|
||||
printf (OutFile "BANK_1_GIN_$World := ");
|
||||
|
||||
foreach $Ride (@RideNamesBank1)
|
||||
{
|
||||
@TheseGins=split(/!/,$RideNameToAnims{$Ride});
|
||||
foreach $Gin (@TheseGins)
|
||||
{
|
||||
printf(OutFile "$GrafDir$Ride/$Gin.gin ");
|
||||
}
|
||||
}
|
||||
|
||||
printf (OutFile "\n");
|
||||
|
||||
|
||||
printf (OutFile "BANK_2_GIN_$World := ");
|
||||
|
||||
foreach $Ride (@RideNamesBank2)
|
||||
{
|
||||
@TheseGins=split(/!/,$RideNameToAnims{$Ride});
|
||||
foreach $Gin (@TheseGins)
|
||||
{
|
||||
printf(OutFile "$GrafDir$Ride/$Gin.gin ");
|
||||
}
|
||||
}
|
||||
printf (OutFile "\n");
|
||||
|
||||
printf (OutFile "\n\n");
|
||||
|
||||
|
||||
foreach $Ride (@RideNames)
|
||||
{
|
||||
@Anims=split(/!/,$RideNameToAnims{$Ride});
|
||||
|
||||
printf (OutFile "$RidesOutDir$Ride.ars : ");
|
||||
|
||||
foreach $RideAnim (@Anims)
|
||||
{printf (OutFile "$RidesDir$Ride/$RideAnim.gin ");}
|
||||
|
||||
print (OutFile "\n\t@\$(ECHO) Creating $Ride.ars from ",join(" ",@Anims));
|
||||
print (OutFile "\n\t\$(");
|
||||
print (OutFile "$World");
|
||||
print (OutFile "_MAKE_RIDE_");
|
||||
print (OutFile "$RideNameToRideBank{$Ride}) ");
|
||||
|
||||
foreach $RideAnim (@Anims)
|
||||
{printf (OutFile "$RidesDir$Ride/$RideAnim.gin ");}
|
||||
|
||||
print (OutFile "\n\n");
|
||||
}
|
||||
|
||||
|
||||
printf(OutFile "\nshared$World");
|
||||
printf(OutFile "1 : \$($SharedOutWorld_1)\n\n");
|
||||
|
||||
printf(OutFile "\nshared$World");
|
||||
printf(OutFile "2 : \$($SharedOutWorld_2)\n\n");
|
||||
|
||||
printf(OutFile "\ncleanshared$World");
|
||||
printf(OutFile "1 :\n\t\$(RM) -f \$($SharedOutWorld_1)\n\n");
|
||||
|
||||
printf(OutFile "\ncleanshared$World");
|
||||
printf(OutFile "2 :\n\t\$(RM) -f \$($SharedOutWorld_2)\n\n");
|
||||
|
||||
printf(OutFile "\nshared$World : \$(shared_out_$World)\n\n");
|
||||
|
||||
printf(OutFile "cleanshared$World : \n\t\$(RM) -f \$(shared_out_$World)\n\n");
|
||||
|
||||
printf(OutFile "\$(shared_out_$World) : \$($World");
|
||||
printf(OutFile "_shared_tx_full)\n");
|
||||
printf(OutFile "\t\$(MAKE_SHARED) \$($World");
|
||||
|
||||
printf(OutFile "_shared_tx_full) \$($World");
|
||||
printf(OutFile "_anim_shared_tx_full)\n\n");
|
||||
|
||||
printf(OutFile "\$(");
|
||||
printf(OutFile $World);
|
||||
printf(OutFile "_ARS_FILES) : \$(shared_out_$World) \$($SharedOutWorld_1) \$($SharedOutWorld_2)\n\n");
|
||||
|
||||
printf(OutFile "\$($SharedOutWorld_1) : \$(BANK_1_GIN_$World)\n\t\$(MAKE_SHARED_1) \$(BANK_1_GIN_$World)\n\n");
|
||||
printf(OutFile "\$($SharedOutWorld_2) : \$(BANK_1_GIN_$World)\n\t\$(MAKE_SHARED_2) \$(BANK_2_GIN_$World)\n\n");
|
||||
|
||||
print (OutFile "make$World : shared$World shared$World");
|
||||
print (OutFile "1 shared$World");
|
||||
print (OutFile "2 \$(",$World,"_ARS_FILES)\n\n");
|
||||
|
||||
print (OutFile "shared$World");
|
||||
print (OutFile "1 shared$World");
|
||||
print (OutFile "2 : shared$World\n");
|
||||
|
||||
printf (OutFile "\n\n");
|
||||
|
||||
print (OutFile "clean$World :\n\t@\$(RM) -f \$(",$World,"_ARS_FILES)\n\t@\$(ECHO) cleaned $World rides\n");
|
||||
|
||||
printf (OutFile "\n");
|
||||
printf (OutFile "\n");
|
||||
|
||||
printf (OutFile "\n\n");
|
||||
|
||||
|
||||
close(OutFile);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
147
tools/Perl/pl/lang.pl
Normal file
147
tools/Perl/pl/lang.pl
Normal file
|
@ -0,0 +1,147 @@
|
|||
#=========================================================================
|
||||
#
|
||||
# LANG.PL
|
||||
#
|
||||
# Author: Gary Liddon @ Climax
|
||||
# Created:
|
||||
# Project: TPW PSX
|
||||
# Purpose:
|
||||
# Usage:
|
||||
#
|
||||
# Copyright (c) 1999 Climax Development Ltd
|
||||
#
|
||||
#===========================================================================
|
||||
|
||||
# PKG - Added check for invalid id tags
|
||||
|
||||
|
||||
#MAIN
|
||||
#{
|
||||
local ($englishFile,$outFile,@langFiles)=@ARGV;
|
||||
|
||||
readTransFile($englishFile,"eng",\%english);
|
||||
|
||||
foreach $Id (keys(%english))
|
||||
{
|
||||
$idToTrans{$Id}="eng=$english{$Id}";
|
||||
}
|
||||
|
||||
|
||||
foreach $file (@langFiles)
|
||||
{
|
||||
local (%otherLang);
|
||||
$otherLang={};
|
||||
|
||||
printf "trying $file\n";
|
||||
|
||||
if ($file=~/^.*\\(.*)\.dat/)
|
||||
{
|
||||
$prefix=$1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($file=~/^.*\/(.*)\.dat/)
|
||||
{
|
||||
$prefix=$1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf "reading $file\n";
|
||||
readTransFile($file,$prefix,\%otherLang);
|
||||
printf "read $file\n";
|
||||
|
||||
foreach $Id (keys(%english))
|
||||
{
|
||||
if ($otherLang{$Id} ne "")
|
||||
{
|
||||
local (@trans)=split(/arsebiscuits/,$idToTrans{$Id});
|
||||
push(@trans,"$prefix=$otherLang{$Id}");
|
||||
$idToTrans{$Id}=join('arsebiscuits',@trans);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($outFile ne "")
|
||||
{
|
||||
$OUTFILE= ">$outFile";
|
||||
|
||||
open(OUTFILE) || die "Can't open file $outFile; $!";
|
||||
|
||||
foreach $Id (keys(%idToTrans))
|
||||
{
|
||||
print (OUTFILE "[$Id]\n");
|
||||
|
||||
local (@trans)=split(/arsebiscuits/,$idToTrans{$Id});
|
||||
|
||||
foreach $text (@trans)
|
||||
{
|
||||
print (OUTFILE "$text\n");
|
||||
}
|
||||
|
||||
print (OUTFILE "\n");
|
||||
}
|
||||
|
||||
close(OUTFILE);
|
||||
}
|
||||
|
||||
#}
|
||||
|
||||
# Read a translation file into an associative array
|
||||
sub readTransFile
|
||||
{
|
||||
local($inFile,$prefix,$destArray)=@_;
|
||||
|
||||
$INFILE = $inFile;
|
||||
|
||||
open(INFILE) || die "Can't open file $inFile; $!";
|
||||
|
||||
while (<INFILE>)
|
||||
{
|
||||
if (/^\[(.*)]\n/)
|
||||
{
|
||||
$id=$1;
|
||||
if($id=~/[^a-zA-Z0-9_]/)
|
||||
{
|
||||
die("Invalid id tag [$id] in $inFile\nTag may only contain a-z, A-Z, 0-9 and _\n");
|
||||
}
|
||||
|
||||
$Done = 0;
|
||||
|
||||
while (!$Done)
|
||||
{
|
||||
$_=<INFILE>;
|
||||
chop $_;
|
||||
s/;.*//g;
|
||||
|
||||
if ($_ ne "")
|
||||
{
|
||||
if (/^(.*)\=(.*)/)
|
||||
{
|
||||
if ($1 eq $prefix)
|
||||
{
|
||||
|
||||
$text=$2;
|
||||
$Done=1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "!$_!";
|
||||
die "incorrectly formatted file $inFile\nlooking for $prefix=<text> for id $id\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$$destArray{$id}="$text";
|
||||
}
|
||||
}
|
||||
|
||||
close(INFILE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#===========================================================================
|
||||
#ends
|
25
tools/Perl/pl/makeconf.pl
Normal file
25
tools/Perl/pl/makeconf.pl
Normal file
|
@ -0,0 +1,25 @@
|
|||
use Win32;
|
||||
|
||||
&WriteConf($ARGV[0],$ARGV[1]);
|
||||
|
||||
sub WriteConf
|
||||
{
|
||||
local ($INFILE,$OutName)=@_;
|
||||
local ($OUTFILE);
|
||||
$OUTFILE=">";
|
||||
$OUTFILE.=$OutName;
|
||||
|
||||
$Name=Win32::LoginName;
|
||||
|
||||
open(INFILE) || die "Can't open in file $INFILE; $!";
|
||||
open(OUTFILE) || die "Can't open output file $OutName; $!";
|
||||
|
||||
while (<INFILE>)
|
||||
{
|
||||
s/\!/$Name/g;
|
||||
print (OUTFILE $_);
|
||||
}
|
||||
|
||||
close($OUTFILE);
|
||||
close(INFILE);
|
||||
}
|
42
tools/Perl/pl/mkbig.pl
Normal file
42
tools/Perl/pl/mkbig.pl
Normal file
|
@ -0,0 +1,42 @@
|
|||
#=========================================================================
|
||||
#
|
||||
# MKSTR.PL
|
||||
#
|
||||
# Author: Gary Liddon @ Climax
|
||||
# Created:
|
||||
# Project: Diablo PSX
|
||||
# Purpose: Makes some bse files from a base file
|
||||
# Usage: pl mkstr.pl <base file> <data dir> <gfx dir> <music dir> <stream sfx dir> <sfx dir>
|
||||
#
|
||||
# Copyright (c) 1997 Climax Development Ltd
|
||||
#
|
||||
#===========================================================================
|
||||
|
||||
|
||||
#MAIN
|
||||
#{
|
||||
|
||||
local ($BaseFile,$BinDir,$OutFile)=@ARGV;
|
||||
|
||||
$OUTFILE=">";
|
||||
$OUTFILE.=$OutFile;
|
||||
|
||||
local ($INFILE)=$BaseFile;
|
||||
|
||||
open(OUTFILE) || die "Can't open output file $OutFile: $!";
|
||||
open(INFILE) || die "Can't open monst inffile $InfFile; $!";
|
||||
|
||||
while (<INFILE>)
|
||||
{
|
||||
s/\[BINDIR\]/$BinDir/g;
|
||||
s/\//\\/g;
|
||||
print (OUTFILE $_);
|
||||
}
|
||||
|
||||
print "written $OutFile\n";
|
||||
|
||||
close(INFILE);
|
||||
close($OUTFILE);
|
||||
#}
|
||||
|
||||
|
48
tools/Perl/pl/mkstr.pl
Normal file
48
tools/Perl/pl/mkstr.pl
Normal file
|
@ -0,0 +1,48 @@
|
|||
#=========================================================================
|
||||
#
|
||||
# MKSTR.PL
|
||||
#
|
||||
# Author: Gary Liddon @ Climax
|
||||
# Created:
|
||||
# Project: Diablo PSX
|
||||
# Purpose: Makes some bse files from a base file
|
||||
# Usage: pl mkstr.pl <base file> <data dir> <gfx dir> <music dir> <stream sfx dir> <sfx dir>
|
||||
#
|
||||
# Copyright (c) 1997 Climax Development Ltd
|
||||
#
|
||||
#===========================================================================
|
||||
|
||||
|
||||
#MAIN
|
||||
#{
|
||||
|
||||
local ($BaseFile,$DataDir,$GfxDir,$VagDir,$SfxDir,$OutFile)=@ARGV;
|
||||
|
||||
#die if ($BaseFile eq "" or $DataDir eq "" or $GfxDir eq "" or $MusicDir eq "" or $StreamSfxDir eq "" or $SfxDir or $OutFile eq "");
|
||||
|
||||
$OUTFILE=">";
|
||||
$OUTFILE.=$OutFile;
|
||||
|
||||
local ($INFILE)=$BaseFile;
|
||||
|
||||
open(OUTFILE) || die "Can't open output file $OutFile: $!";
|
||||
open(INFILE) || die "Can't open monst inffile $InfFile; $!";
|
||||
|
||||
while (<INFILE>)
|
||||
{
|
||||
s/\[DATA\]/$DataDir/g;
|
||||
s/\[GFX\]/$GfxDir/g;
|
||||
s/\[VAG\]/$VagDir/g;
|
||||
s/\[SFX\]/$SfxDir/g;
|
||||
s/\//\\/g;
|
||||
print (OUTFILE $_);
|
||||
}
|
||||
|
||||
print "written $OutFile\n";
|
||||
|
||||
close(INFILE);
|
||||
close($OUTFILE);
|
||||
|
||||
#}
|
||||
|
||||
|
22
tools/Perl/pl/notused.pl
Normal file
22
tools/Perl/pl/notused.pl
Normal file
|
@ -0,0 +1,22 @@
|
|||
while (<>)
|
||||
{
|
||||
if (/^\s+.*\s+(\d+)\s+(\d+)\s+(\d+)/)
|
||||
{
|
||||
if ($1 eq "0")
|
||||
{
|
||||
if ($2 eq "0")
|
||||
{
|
||||
if ($3 eq "0")
|
||||
{
|
||||
print "$_";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $_;
|
||||
|
||||
}
|
||||
}
|
64
tools/Perl/pl/shops.pl
Normal file
64
tools/Perl/pl/shops.pl
Normal file
|
@ -0,0 +1,64 @@
|
|||
$OutFile=shift(@ARGV);
|
||||
$World=shift(@ARGV);
|
||||
$Type=shift(@ARGV);
|
||||
$Command=shift(@ARGV);
|
||||
$DataOut=shift(@ARGV);
|
||||
$GrafDir=shift(@ARGV);
|
||||
|
||||
$OutFile=">$OutFile";
|
||||
|
||||
open(OutFile) || die "Can't open in file $OutFile; $!";
|
||||
|
||||
printf(OutFile "ifdef POO\n");
|
||||
|
||||
printf(OutFile ".PHONY : $World$Type clean$World$Type\n\n");
|
||||
|
||||
foreach $Val (@ARGV)
|
||||
{
|
||||
@Stuff=split(/-/,$Val);
|
||||
$ArsName=shift(@Stuff);
|
||||
|
||||
push(@ArsNames,$ArsName);
|
||||
|
||||
$ArsNameToAnims{$ArsName}=join('!',@Stuff);
|
||||
}
|
||||
|
||||
printf(OutFile "$World$Type");
|
||||
printf(OutFile "_ARS_FILES := ");
|
||||
|
||||
foreach $Ars (@ArsNames)
|
||||
{printf(OutFile "$DataOut$Ars.ars ");}
|
||||
|
||||
printf(OutFile "\n");
|
||||
|
||||
foreach $Ars (@ArsNames)
|
||||
{
|
||||
printf(OutFile "$DataOut$Ars.ars : ");
|
||||
|
||||
@Anims=split(/!/,$ArsNameToAnims{$Ars});
|
||||
|
||||
foreach $Anim (@Anims)
|
||||
{printf(OutFile "$GrafDir$Ars/$Anim.gin ");}
|
||||
|
||||
printf(OutFile "\n\t$Command ");
|
||||
|
||||
foreach $Anim (@Anims)
|
||||
{printf(OutFile "$GrafDir$Ars/$Anim.gin ");}
|
||||
|
||||
printf(OutFile "\n\n");
|
||||
}
|
||||
|
||||
printf(OutFile "$World$Type : \$($World$Type");
|
||||
printf(OutFile "_ARS_FILES)\n\n");
|
||||
|
||||
printf(OutFile "clean$World$Type :\n");
|
||||
printf(OutFile "\t\@\$(RM) -f \$($World$Type");
|
||||
printf(OutFile "_ARS_FILES)\n");
|
||||
printf(OutFile "\t\@\$(ECHO) Cleaned $World $Type\n");
|
||||
|
||||
printf(OutFile "\n\nendif");
|
||||
|
||||
close(OutFile);
|
||||
|
||||
|
||||
|
37
tools/Perl/pl/size.pl
Normal file
37
tools/Perl/pl/size.pl
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
&PrintSize($ARGV[0]);
|
||||
|
||||
|
||||
sub PrintSize
|
||||
{
|
||||
local ($INFILE)=@_;
|
||||
|
||||
open(INFILE) || die "Can't open in file $INFILE; $!";
|
||||
|
||||
while (<INFILE>)
|
||||
{
|
||||
chop $_;
|
||||
|
||||
if (/^\s[A-Z0-9]+\s([A-Z0-9]+)\s[A-Z0-9]+\s[A-Z0-9]+\s\w+\s+\.last/)
|
||||
{
|
||||
$Addr=$1;
|
||||
|
||||
$Addr=hex($Addr)-hex("80000000");
|
||||
$Over=$Addr-(2*1024*1024);
|
||||
if ($Over ge 0)
|
||||
{
|
||||
print "Size is $Addr ($Over over)\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$Over=0-$Over;
|
||||
print "Size is $Addr ($Over to spare)\n";
|
||||
}
|
||||
last;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
51
tools/Perl/pl/sizes.pl
Normal file
51
tools/Perl/pl/sizes.pl
Normal file
|
@ -0,0 +1,51 @@
|
|||
&GetSizes($ARGV[0]);
|
||||
|
||||
|
||||
|
||||
sub GetSizes
|
||||
{
|
||||
local ($INFILE)=@_;
|
||||
|
||||
open(INFILE) || die "Can't open in file $INFILE; $!";
|
||||
|
||||
while (<INFILE>)
|
||||
{
|
||||
last if (/.*Names in address order/);
|
||||
}
|
||||
|
||||
while (<INFILE>)
|
||||
{
|
||||
chop $_;
|
||||
|
||||
if (/^\s([A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9])\s(.*)/)
|
||||
{
|
||||
$Addr=$1;
|
||||
$Label=$2;
|
||||
$Addr=hex($Addr);
|
||||
|
||||
if ($Addr >= hex("80000000"))
|
||||
{
|
||||
if (!$Seen{$Label})
|
||||
{
|
||||
$Seen{$Label}++;
|
||||
$Addr=$Addr-hex("80000000");
|
||||
|
||||
if ($LastLabel ne "")
|
||||
{
|
||||
print "$LastLabel\tsize\t",$Addr-$LastAddr,"\n";
|
||||
}
|
||||
|
||||
$LastAddr=$Addr;
|
||||
$LastLabel=$Label;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
close(INFILE);
|
||||
}
|
96
tools/Perl/pl/stats.pl
Normal file
96
tools/Perl/pl/stats.pl
Normal file
|
@ -0,0 +1,96 @@
|
|||
|
||||
while (<>)
|
||||
{
|
||||
/^.*:\s+(.*)\n/;
|
||||
$CodeFile=$1;
|
||||
|
||||
if ($CodeFile ne "")
|
||||
{
|
||||
$Code=<>;
|
||||
$Data=<>;
|
||||
$Bss=<>;
|
||||
<>;
|
||||
|
||||
$Code=&GetNum($Code);
|
||||
$Data=&GetNum($Data);
|
||||
$Bss=&GetNum($Bss);;
|
||||
|
||||
$CodeSizeToFile{$Code}.="!" if ($CodeSizeToFile{$Code} ne "");
|
||||
$CodeSizeToFile{$Code}.=$CodeFile;
|
||||
|
||||
$DataSizeToFile{$Data}.="!" if ($DataSizeToFile{$Data} ne "");
|
||||
$DataSizeToFile{$Data}.=$CodeFile;
|
||||
|
||||
$BssSizeToFile{$Bss}.="!" if ($BssSizeToFile{$Bss} ne "");
|
||||
$BssSizeToFile{$Bss}.=$CodeFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
die "Strange line $_";
|
||||
}
|
||||
}
|
||||
|
||||
print "Code Section\n";
|
||||
print "------------\n";
|
||||
|
||||
foreach $Num (sort numerically keys(%CodeSizeToFile))
|
||||
{
|
||||
local(@Files)=split(/!/,$CodeSizeToFile{$Num});
|
||||
|
||||
foreach $File (@Files)
|
||||
{
|
||||
print "$File\t$Num\n";
|
||||
}
|
||||
}
|
||||
|
||||
print "\n";
|
||||
|
||||
|
||||
print "Data Section\n";
|
||||
print "------------\n";
|
||||
|
||||
foreach $Num (sort numerically keys(%DataSizeToFile))
|
||||
{
|
||||
local(@Files)=split(/!/,$DataSizeToFile{$Num});
|
||||
|
||||
foreach $File (@Files)
|
||||
{
|
||||
print "$File\t$Num\n";
|
||||
}
|
||||
}
|
||||
|
||||
print "\n";
|
||||
|
||||
print "Bss Section\n";
|
||||
print "-----------\n";
|
||||
|
||||
foreach $Num (sort numerically keys(%BssSizeToFile))
|
||||
{
|
||||
local(@Files)=split(/!/,$BssSizeToFile{$Num});
|
||||
|
||||
foreach $File (@Files)
|
||||
{
|
||||
print "$File\t$Num\n";
|
||||
}
|
||||
}
|
||||
|
||||
print "\n";
|
||||
|
||||
sub GetNum
|
||||
{
|
||||
local ($Line)=@_;
|
||||
|
||||
if ($Line=~/^\s+\w+\s+size:\s+(\d+)/)
|
||||
{
|
||||
($1);
|
||||
}
|
||||
else
|
||||
{
|
||||
die "Fuck";
|
||||
}
|
||||
|
||||
($1);
|
||||
}
|
||||
|
||||
|
||||
sub numerically { $b <=> $a;}
|
21
tools/Perl/pl/user.pl
Normal file
21
tools/Perl/pl/user.pl
Normal file
|
@ -0,0 +1,21 @@
|
|||
use Win32;
|
||||
|
||||
if ($ARGV[0] ne "")
|
||||
{
|
||||
&WriteUserFile($ARGV[0]);
|
||||
}
|
||||
|
||||
sub WriteUserFile
|
||||
{
|
||||
local ($OutName)=@_;
|
||||
local ($OUTFILE);
|
||||
$OUTFILE=">";
|
||||
$OUTFILE.=$OutName;
|
||||
|
||||
open(OUTFILE) || die "Can't open output file $OutName; $!";
|
||||
|
||||
$Name=lc(Win32::LoginName);
|
||||
print (OUTFILE "USER_NAME := $Name\n");
|
||||
|
||||
close($OUTFILE);
|
||||
}
|
BIN
tools/chkshare.exe
Normal file
BIN
tools/chkshare.exe
Normal file
Binary file not shown.
BIN
tools/cygwin/a.exe
Normal file
BIN
tools/cygwin/a.exe
Normal file
Binary file not shown.
BIN
tools/cygwin/addr2line.exe
Normal file
BIN
tools/cygwin/addr2line.exe
Normal file
Binary file not shown.
BIN
tools/cygwin/ar.exe
Normal file
BIN
tools/cygwin/ar.exe
Normal file
Binary file not shown.
BIN
tools/cygwin/as.exe
Normal file
BIN
tools/cygwin/as.exe
Normal file
Binary file not shown.
BIN
tools/cygwin/awk.exe
Normal file
BIN
tools/cygwin/awk.exe
Normal file
Binary file not shown.
BIN
tools/cygwin/basename.exe
Normal file
BIN
tools/cygwin/basename.exe
Normal file
Binary file not shown.
BIN
tools/cygwin/bash.exe
Normal file
BIN
tools/cygwin/bash.exe
Normal file
Binary file not shown.
143
tools/cygwin/bashbug
Normal file
143
tools/cygwin/bashbug
Normal file
|
@ -0,0 +1,143 @@
|
|||
#!/bin/sh -
|
||||
#
|
||||
# bashbug - create a bug report and mail it to the bug address
|
||||
#
|
||||
# The bug address depends on the release status of the shell. Versions
|
||||
# with status `alpha' or `beta' mail bug reports to chet@po.cwru.edu.
|
||||
# Other versions send mail to bug-bash@gnu.org.
|
||||
#
|
||||
# configuration section:
|
||||
# these variables are filled in by the make target in cpp-Makefile
|
||||
#
|
||||
MACHINE="i586"
|
||||
OS="cygwin32"
|
||||
CC="i586-cygwin32-gcc"
|
||||
CFLAGS=" -DPROGRAM='bash.exe' -DHOSTTYPE='i586' -DOSTYPE='cygwin32' -DMACHTYPE='i586-pc-cygwin32' -DCROSS_COMPILING -DSHELL -DHAVE_CONFIG_H -I. -I/home/noer/src/b20/user-tools/devo/bash -I/home/noer/src/b20/user-tools/devo/bash/lib -O2"
|
||||
RELEASE="2.02"
|
||||
PATCHLEVEL="1"
|
||||
RELSTATUS="release"
|
||||
MACHTYPE="i586-pc-cygwin32"
|
||||
|
||||
PATH=/bin:/usr/bin:/usr/local/bin:$PATH
|
||||
export PATH
|
||||
|
||||
TEMP=/tmp/bbug.$$
|
||||
|
||||
# Figure out how to echo a string without a trailing newline
|
||||
N=`echo 'hi there\c'`
|
||||
case "$N" in
|
||||
*c) n=-n c= ;;
|
||||
*) n= c='\c' ;;
|
||||
esac
|
||||
|
||||
BASHTESTERS="bash-testers@po.cwru.edu"
|
||||
|
||||
case "$RELSTATUS" in
|
||||
alpha*|beta*) BUGBASH=chet@po.cwru.edu ;;
|
||||
*) BUGBASH=bug-bash@gnu.org ;;
|
||||
esac
|
||||
|
||||
case "$RELSTATUS" in
|
||||
alpha*|beta*) echo "$0: This is a testing release. Would you like your bug report"
|
||||
echo "$0: to be sent to the bash-testers mailing list?"
|
||||
echo $n "$0: Send to bash-testers? $c"
|
||||
read ans
|
||||
case "$ans" in
|
||||
y*|Y*) BUGBASH="${BUGBASH},${BASHTESTERS}" ;;
|
||||
esac ;;
|
||||
esac
|
||||
|
||||
BUGADDR="${1-$BUGBASH}"
|
||||
|
||||
: ${EDITOR=emacs}
|
||||
|
||||
: ${USER=${LOGNAME-`whoami`}}
|
||||
|
||||
trap 'rm -f $TEMP $TEMP.x; exit 1' 1 2 3 13 15
|
||||
trap 'rm -f $TEMP $TEMP.x' 0
|
||||
|
||||
UN=
|
||||
if (uname) >/dev/null 2>&1; then
|
||||
UN=`uname -a`
|
||||
fi
|
||||
|
||||
if [ -f /usr/lib/sendmail ] ; then
|
||||
RMAIL="/usr/lib/sendmail"
|
||||
elif [ -f /usr/sbin/sendmail ] ; then
|
||||
RMAIL="/usr/sbin/sendmail"
|
||||
else
|
||||
RMAIL=rmail
|
||||
fi
|
||||
|
||||
# this is raceable
|
||||
rm -f $TEMP
|
||||
|
||||
cat > $TEMP <<EOF
|
||||
From: ${USER}
|
||||
To: ${BUGADDR}
|
||||
Subject: [50 character or so descriptive subject here (for reference)]
|
||||
|
||||
Configuration Information [Automatically generated, do not change]:
|
||||
Machine: $MACHINE
|
||||
OS: $OS
|
||||
Compiler: $CC
|
||||
Compilation CFLAGS: $CFLAGS
|
||||
uname output: $UN
|
||||
Machine Type: $MACHTYPE
|
||||
|
||||
Bash Version: $RELEASE
|
||||
Patch Level: $PATCHLEVEL
|
||||
Release Status: $RELSTATUS
|
||||
|
||||
Description:
|
||||
[Detailed description of the problem, suggestion, or complaint.]
|
||||
|
||||
Repeat-By:
|
||||
[Describe the sequence of events that causes the problem
|
||||
to occur.]
|
||||
|
||||
Fix:
|
||||
[Description of how to fix the problem. If you don't know a
|
||||
fix for the problem, don't include this section.]
|
||||
EOF
|
||||
|
||||
# this is still raceable
|
||||
rm -f $TEMP.x
|
||||
cp $TEMP $TEMP.x
|
||||
chmod u+w $TEMP
|
||||
|
||||
trap '' 2 # ignore interrupts while in editor
|
||||
|
||||
until $EDITOR $TEMP; do
|
||||
echo "$0: editor \`$EDITOR' exited with nonzero status."
|
||||
echo "$0: Perhaps it was interrupted."
|
||||
echo "$0: Type \`y' to give up, and lose your bug report;"
|
||||
echo "$0: type \`n' to re-enter the editor."
|
||||
echo $n "$0: Do you want to give up? $c"
|
||||
|
||||
read ans
|
||||
case "$ans" in
|
||||
[Yy]*) exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
trap 'rm -f $TEMP $TEMP.x; exit 1' 2 # restore trap on SIGINT
|
||||
|
||||
if cmp -s $TEMP $TEMP.x
|
||||
then
|
||||
echo "File not changed, no bug report submitted."
|
||||
exit
|
||||
fi
|
||||
|
||||
echo $n "Send bug report? [y/n] $c"
|
||||
read ans
|
||||
case "$ans" in
|
||||
[Nn]*) exit 0 ;;
|
||||
esac
|
||||
|
||||
${RMAIL} $BUGADDR < $TEMP || {
|
||||
cat $TEMP >> $HOME/dead.bashbug
|
||||
echo "$0: mail failed: report saved in $HOME/dead.bashbug" >&2
|
||||
}
|
||||
|
||||
exit 0
|
BIN
tools/cygwin/bison.exe
Normal file
BIN
tools/cygwin/bison.exe
Normal file
Binary file not shown.
BIN
tools/cygwin/bunzip2.exe
Normal file
BIN
tools/cygwin/bunzip2.exe
Normal file
Binary file not shown.
BIN
tools/cygwin/byacc.exe
Normal file
BIN
tools/cygwin/byacc.exe
Normal file
Binary file not shown.
BIN
tools/cygwin/bzcat.exe
Normal file
BIN
tools/cygwin/bzcat.exe
Normal file
Binary file not shown.
BIN
tools/cygwin/bzip2.exe
Normal file
BIN
tools/cygwin/bzip2.exe
Normal file
Binary file not shown.
BIN
tools/cygwin/bzip2recover.exe
Normal file
BIN
tools/cygwin/bzip2recover.exe
Normal file
Binary file not shown.
BIN
tools/cygwin/c++.exe
Normal file
BIN
tools/cygwin/c++.exe
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue