This commit is contained in:
parent
d8dc188f90
commit
1d87e8a0c7
3 changed files with 824 additions and 0 deletions
649
Utils/MkActor/MkActor.cpp
Normal file
649
Utils/MkActor/MkActor.cpp
Normal file
|
@ -0,0 +1,649 @@
|
|||
/*************************/
|
||||
/*** Actor Sprite Tool ***/
|
||||
/*************************/
|
||||
|
||||
#include "stdio.h"
|
||||
#include <misc.hpp>
|
||||
#include <conio.h>
|
||||
#include <iostream.h>
|
||||
#include <vector>
|
||||
#include <DaveLib.h>
|
||||
#include <io.h>
|
||||
|
||||
#include "MkActor.h"
|
||||
|
||||
#include <pak.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
//***************************************************************************
|
||||
vector<CMkActor> ActorList;
|
||||
int TPBase=-1,TPWidth=-1,TPHeight=-1;
|
||||
GString TPOutStr;
|
||||
|
||||
GString RootPath;
|
||||
GString SpritePath;
|
||||
GString OutPath;
|
||||
GString IncludePath;
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
char * CycleCommands(char *String,int Num)
|
||||
{
|
||||
char Text[2048],*TextPtr;
|
||||
int Count;
|
||||
|
||||
if (String[0]=='-' || String[0]=='/')
|
||||
{
|
||||
GString TpStr;
|
||||
switch (String[1])
|
||||
{
|
||||
// Switches
|
||||
case 'o':
|
||||
OutPath = CheckFileString(String);
|
||||
OutPath.Upper();
|
||||
OutPath.Append('\\');
|
||||
break;
|
||||
case 'i':
|
||||
IncludePath = CheckFileString(String);
|
||||
IncludePath.Upper();
|
||||
IncludePath.Append('\\');
|
||||
break;
|
||||
case 'd':
|
||||
DebugOn =true;
|
||||
break;
|
||||
case 's':
|
||||
SpritePath=CheckFileString(String);
|
||||
SpritePath.Upper();
|
||||
SpritePath.Append('\\');
|
||||
break;
|
||||
case 'r':
|
||||
RootPath=CheckFileString(String);
|
||||
RootPath.Upper();
|
||||
RootPath.Append('\\');
|
||||
break;
|
||||
case 't':
|
||||
TpStr= CheckFileString(String);
|
||||
TextPtr=Text;
|
||||
strcpy(TextPtr,TpStr);
|
||||
Count=ZeroAndCountCommas(TextPtr);
|
||||
if (Count!=2) GObject::Error(ERR_FATAL,"Problem with option %s\n",String);
|
||||
TPBase=atol(TextPtr);
|
||||
TextPtr+=strlen(TextPtr)+1;
|
||||
TPWidth=atol(TextPtr);
|
||||
TextPtr+=strlen(TextPtr)+1;
|
||||
TPHeight=atol(TextPtr);
|
||||
break;
|
||||
default:
|
||||
GObject::Error(ERR_FATAL,"Unknown switch %s",String);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GString Name=String;
|
||||
Name.Upper();
|
||||
ActorList.push_back(CMkActor(Name,RootPath,SpritePath));
|
||||
}
|
||||
|
||||
return(String);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
void Usage(char *ErrStr)
|
||||
{
|
||||
printf("\nMkActor (usese scripts): by Dave\n");
|
||||
printf("Usage: MkActor <file> [ <file>.. ] [ switches.. ]\n");
|
||||
printf("Switches:\n");
|
||||
printf(" -o:[FILE] Set output Dir\n");
|
||||
printf(" -p:nn Root Dir\n");
|
||||
printf(" -s:nn Sprite Dir\n");
|
||||
printf(" -t:p,w,h Set TPage No,Width,Height\n");
|
||||
printf(" -d: Enable Debug output\n");
|
||||
GObject::Error(ERR_FATAL,ErrStr);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
int i,ListSize;
|
||||
|
||||
CommandLine(argc,argv,CycleCommands);
|
||||
if (OutPath.Empty()) Usage("No Output File Set\n");
|
||||
|
||||
ListSize=ActorList.size();
|
||||
for (i=0; i<ListSize; i++)
|
||||
{
|
||||
ActorList[i].Load();
|
||||
ActorList[i].Process();
|
||||
ActorList[i].Write();
|
||||
ActorList[i].CleanUp();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
//***************************************************************************
|
||||
//***************************************************************************
|
||||
CMkActor::CMkActor(GString &ActorName,GString &ActorPath,GString &SpritePath)
|
||||
{
|
||||
Name=ActorName;
|
||||
ActorDir=ActorPath+ActorName;
|
||||
ActorDir.Append('\\');
|
||||
SpriteDir=ActorDir+SpritePath;
|
||||
OutFile=OutPath+ActorName;
|
||||
IncFile=IncludePath+"ACTOR_"+Name;
|
||||
|
||||
TexGrab.SetTPage(TPBase,TPWidth,TPHeight);
|
||||
TexGrab.SetOutFile(OutFile+".Tex");
|
||||
TexGrab.SetDebugOut(OutFile+".Lbm");
|
||||
TexGrab.SetIncFile(IncFile+"_TEX.h");
|
||||
TexGrab.NoSort();
|
||||
TexGrab.AnimatedHeadersOnly(true);
|
||||
TexGrab.DontOutputBoxes(true);
|
||||
TexGrab.AllowRotate(false);
|
||||
|
||||
DupCount=0;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
void CMkActor::CleanUp()
|
||||
{
|
||||
int i,ListSize=BmpList.size();
|
||||
|
||||
for (i=0; i<ListSize; i++)
|
||||
{
|
||||
if (BmpList[i].RGB) free(BmpList[i].RGB);
|
||||
if (BmpList[i].Pak) free(BmpList[i].Pak);
|
||||
if (BmpList[i].Psx) free(BmpList[i].Psx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//***************************************************************************
|
||||
void CMkActor::Load()
|
||||
{
|
||||
ReadScript(ActorDir+"AnimList.Txt",InAnimList);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
void CMkActor::ReadScript(const char *Filename,vector<GString> &List)
|
||||
{
|
||||
char *Script,*Ptr;
|
||||
int Size;
|
||||
|
||||
File=fopen(Filename,"rb");
|
||||
if (!File) return;
|
||||
fseek(File,0,SEEK_END);
|
||||
Size=ftell(File);
|
||||
fseek(File,0,SEEK_SET);
|
||||
Script=(char*)malloc(Size+1);
|
||||
ASSERT(Script);
|
||||
// Load It
|
||||
fread(Script,Size,1,File);
|
||||
fclose(File);
|
||||
|
||||
// Extract Names
|
||||
Ptr=Script;
|
||||
Script[Size]=0;
|
||||
while (*Ptr)
|
||||
{
|
||||
GString Str;
|
||||
|
||||
while (*Ptr=='\n' || *Ptr=='\r'|| *Ptr==' ') *Ptr++; // Skip gaff
|
||||
if (*Ptr)
|
||||
{
|
||||
if (*Ptr=='#')
|
||||
{ // Skip commented lines
|
||||
while (*Ptr!='\n' && *Ptr) Ptr++;
|
||||
}
|
||||
else
|
||||
{ // Read data
|
||||
while (*Ptr!=' ' && *Ptr!='\n' && *Ptr!='\r' && *Ptr)
|
||||
{
|
||||
Str.Append(*Ptr++);
|
||||
}
|
||||
List.push_back(Str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(Script);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
void CMkActor::BuildFrameList()
|
||||
{
|
||||
int i,ListSize=InAnimList.size();
|
||||
char AnimName[256];
|
||||
AnimList.resize(ListSize);
|
||||
for (i=0; i<ListSize; i++)
|
||||
{
|
||||
sAnim &ThisAnim=AnimList[i];
|
||||
sprintf(AnimName,"%s",InAnimList[i]);
|
||||
if (AnimName[0]=='~')
|
||||
{ // VRam Sprite
|
||||
ThisAnim.Name=&AnimName[1];
|
||||
ThisAnim.VRamFlag=true;
|
||||
}
|
||||
else
|
||||
{ // PAK Sprite
|
||||
ThisAnim.Name=&AnimName[0];
|
||||
ThisAnim.VRamFlag=false;
|
||||
}
|
||||
FindFrames(ThisAnim);
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
void CMkActor::FindFrames(sAnim &ThisAnim)
|
||||
{
|
||||
GString Filename;
|
||||
_finddata_t Find;
|
||||
long FileHandle;
|
||||
int Error=0;
|
||||
|
||||
Filename=SpriteDir+Name+"_"+ThisAnim.Name+"*.bmp";
|
||||
if( (FileHandle= _findfirst( Filename, &Find)) == -1L )
|
||||
{
|
||||
printf( "No files in current directory!\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
while (Error==0)
|
||||
{
|
||||
sFrame NewFrame;
|
||||
NewFrame.Filename=Find.name;
|
||||
ThisAnim.Frames.push_back(NewFrame);
|
||||
Error=_findnext( FileHandle, &Find);
|
||||
}
|
||||
_findclose( FileHandle);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
void CMkActor::LoadFrameList()
|
||||
{
|
||||
int i,ListSize=AnimList.size();
|
||||
|
||||
for (i=0; i<ListSize; i++)
|
||||
{
|
||||
sAnim &ThisAnim=AnimList[i];
|
||||
int FrameCount=ThisAnim.Frames.size();
|
||||
for (int f=0; f<FrameCount; f++)
|
||||
{
|
||||
printf("%s - Load Anim %2d/%2d\tFrame %2d/%2d\r",Name,i+1,ListSize,f,FrameCount);
|
||||
LoadFrame(ThisAnim.Frames[f],ThisAnim.VRamFlag);
|
||||
}
|
||||
}
|
||||
printf("\t\t\t\t\t\t\r");
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
void CMkActor::LoadFrame(sFrame &ThisFrame,bool VRamFlag)
|
||||
{
|
||||
ThisFrame.FrameIdx=LoadBmp(ThisFrame.Filename,VRamFlag);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
void CMkActor::MakePsxGfx(sBmp &Bmp)
|
||||
{
|
||||
// Copied from SprSet
|
||||
// apparantly only works on 16 colors, so I gotta watch it!!
|
||||
int AlignPixels=4;
|
||||
int nfW,nfH,nfLineWidthBytes,nfAreaBytes;
|
||||
Frame &Frm=Bmp.Bmp;
|
||||
Rect OriginalRect;
|
||||
|
||||
OriginalRect=Frm;
|
||||
|
||||
OriginalRect.X=0;
|
||||
OriginalRect.Y=0;
|
||||
OriginalRect.W=GU_AlignVal(OriginalRect.W,AlignPixels);
|
||||
|
||||
Frm.Crop(OriginalRect);
|
||||
|
||||
nfW=Frm.GetWidth();
|
||||
nfH=Frm.GetHeight();
|
||||
nfLineWidthBytes=GU_AlignVal(nfW,2)/2;
|
||||
nfAreaBytes=nfLineWidthBytes*nfH;
|
||||
Bmp.PsxSize=nfAreaBytes;
|
||||
|
||||
Bmp.Psx=(u8*)malloc(nfAreaBytes);
|
||||
ASSERT(Bmp.Psx);
|
||||
|
||||
for (int y=0;y<nfH;y++)
|
||||
{
|
||||
for (int x=0;x<nfW;x++)
|
||||
{
|
||||
u8 * PixAddr;
|
||||
u8 ScrNib;
|
||||
|
||||
ScrNib=Frm.SeeData()[y*nfW+x]&0xf;
|
||||
|
||||
PixAddr=&Bmp.Psx[(x/2)+(nfLineWidthBytes*y)];
|
||||
|
||||
if (PixAddr>&Bmp.Psx[nfAreaBytes]) printf("!");
|
||||
if ((x&1))
|
||||
{
|
||||
*PixAddr&=0x0f;
|
||||
*PixAddr|=ScrNib<<4;
|
||||
}
|
||||
else
|
||||
{
|
||||
*PixAddr&=0xf0;
|
||||
*PixAddr|=ScrNib;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
int CMkActor::LoadBmp(GString &Name,bool VRamFlag)
|
||||
{
|
||||
GString Filename=SpriteDir+Name;
|
||||
|
||||
int Idx,i,ListSize;
|
||||
int W,H,Size;
|
||||
sBmp NewBmp;
|
||||
Frame &Bmp=NewBmp.Bmp;
|
||||
|
||||
NewBmp.Filename=Filename;
|
||||
NewBmp.RGB=0;
|
||||
NewBmp.Pak=0;
|
||||
NewBmp.Psx=0;
|
||||
NewBmp.VRamFlag=VRamFlag;
|
||||
Bmp.LoadBMP(Filename);
|
||||
W=Bmp.GetWidth();
|
||||
H=Bmp.GetHeight();
|
||||
Size=W*H;
|
||||
NewBmp.RGB=(u8*)malloc(Size*3);
|
||||
ASSERT(NewBmp.RGB);
|
||||
Bmp.MakeRGB(NewBmp.RGB);
|
||||
|
||||
#if _DEBUG && 0
|
||||
{
|
||||
u8 *TGA=(u8*)malloc(Size*3);
|
||||
ASSERT(TGA);
|
||||
Bmp.FlipY();
|
||||
Bmp.MakeRGB(TGA);
|
||||
Bmp.FlipY();
|
||||
|
||||
char OutName[256];
|
||||
sprintf(OutName,"\\x\\%s.tga",Name);
|
||||
SaveTGA(OutName,W,H,TGA,true);
|
||||
free(TGA);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Gen Chksum
|
||||
u8 *RGB=NewBmp.RGB;
|
||||
NewBmp.ChkR=NewBmp.ChkG=NewBmp.ChkB=0;
|
||||
for (i=0; i<Size; i++)
|
||||
{
|
||||
NewBmp.ChkR+=*RGB++;
|
||||
NewBmp.ChkG+=*RGB++;
|
||||
NewBmp.ChkB+=*RGB++;
|
||||
}
|
||||
|
||||
ListSize=BmpList.size();
|
||||
Idx=-1;
|
||||
// Find existing
|
||||
for (i=0; i<ListSize && Idx==-1; i++)
|
||||
{
|
||||
sBmp &ThisBmp=BmpList[i];
|
||||
if (ThisBmp.Filename==Filename) Idx=i;
|
||||
if (ThisBmp.ChkR==NewBmp.ChkR && ThisBmp.ChkG==NewBmp.ChkG && ThisBmp.ChkB==NewBmp.ChkB)
|
||||
{
|
||||
if (IsImageSame(ThisBmp,NewBmp)) Idx=i;
|
||||
}
|
||||
}
|
||||
|
||||
if (Idx!=-1)
|
||||
{
|
||||
DupCount++;
|
||||
free(NewBmp.RGB);
|
||||
return(Idx);
|
||||
}
|
||||
|
||||
MakePsxGfx(NewBmp);
|
||||
BmpList.push_back(NewBmp);
|
||||
if (VRamFlag)
|
||||
{
|
||||
TexGrab.AddMemFrame(NewBmp.Filename,NewBmp.Bmp);
|
||||
}
|
||||
return(ListSize);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
bool CMkActor::IsImageSame(sBmp &Bmp0,sBmp &Bmp1)
|
||||
{
|
||||
int W0=Bmp0.Bmp.GetWidth();
|
||||
int H0=Bmp0.Bmp.GetHeight();
|
||||
int W1=Bmp1.Bmp.GetWidth();
|
||||
int H1=Bmp1.Bmp.GetHeight();
|
||||
int Size=W0*H0*3;
|
||||
u8 *RGB0=Bmp0.RGB;
|
||||
u8 *RGB1=Bmp1.RGB;
|
||||
|
||||
if (W0!=W1 || H0!=H1) return(false);
|
||||
|
||||
for (int i=0; i<Size; i++)
|
||||
{
|
||||
if (*RGB0++!=*RGB1++) return(false);
|
||||
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
//***************************************************************************
|
||||
//***************************************************************************
|
||||
//***************************************************************************
|
||||
void CMkActor::Process()
|
||||
{
|
||||
BuildFrameList();
|
||||
LoadFrameList();
|
||||
ProcessFrames();
|
||||
|
||||
// TexGrab.Process();
|
||||
}
|
||||
|
||||
|
||||
//***************************************************************************
|
||||
void CMkActor::ProcessFrames()
|
||||
{
|
||||
int i,ListSize=BmpList.size();
|
||||
int TotalIn=0;
|
||||
int TotalOut=0;
|
||||
|
||||
for (i=0; i<ListSize; i++)
|
||||
{
|
||||
sBmp &ThisBmp=BmpList[i];
|
||||
|
||||
printf("%s - Processing Frame %2d\\%2d\r",Name,i+1,ListSize);
|
||||
ThisBmp.PakSize=PAK_findPakSize(ThisBmp.Psx,ThisBmp.PsxSize);
|
||||
ThisBmp.Pak=(u8*)malloc(ThisBmp.PakSize);
|
||||
ASSERT(ThisBmp.Pak);
|
||||
PAK_doPak(ThisBmp.Pak,ThisBmp.Psx,ThisBmp.PsxSize);
|
||||
|
||||
TotalIn+=ThisBmp.PsxSize;
|
||||
TotalOut+=ThisBmp.PakSize;
|
||||
}
|
||||
printf("\t\t\t\t\t\r");
|
||||
printf("%s - Done. %i Dups (In %i) (Out %i) (Saved %i)\n",Name,DupCount,TotalIn,TotalOut,TotalIn-TotalOut);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
//***************************************************************************
|
||||
//***************************************************************************
|
||||
void CMkActor::Write()
|
||||
{
|
||||
GString OutName=OutFile+".SBK";
|
||||
|
||||
// printf("Writing %s\n",Name);
|
||||
File=fopen(OutName,"wb");
|
||||
|
||||
// Write Dummy Hdr
|
||||
fwrite(&FileHdr,1,sizeof(sSpriteAnimBank),File);
|
||||
// Write Palette
|
||||
FileHdr.Palette=(u8*)WritePalette();
|
||||
// Write AnimList
|
||||
FileHdr.AnimList=(sSpriteAnim*)WriteAnimList();
|
||||
// Write FrameList
|
||||
FileHdr.FrameList=(sSpriteFrame*)WriteFrameList();
|
||||
|
||||
// Rewrite Header
|
||||
fseek(File, 0, SEEK_SET);
|
||||
fwrite(&FileHdr,1,sizeof(sSpriteAnimBank),File);
|
||||
fclose(File);
|
||||
|
||||
WriteInclude();
|
||||
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
int CMkActor::WritePalette()
|
||||
{
|
||||
int Pos=ftell(File);
|
||||
Palette &PCPalette=BmpList[0].Bmp.GetPal();
|
||||
SprPal PsxPalette;
|
||||
int i,Count;
|
||||
vector<u16> OutPal;
|
||||
|
||||
PsxPalette=PCPalette;
|
||||
PsxPalette.SetPlusColZero(true);
|
||||
|
||||
Count=PsxPalette.GetNumOfCols();
|
||||
FileHdr.ColorCount=Count;
|
||||
PsxPalette.MakePSXPal(OutPal);
|
||||
for (i=0; i<Count; i++)
|
||||
{
|
||||
u16 ThisCol=OutPal[i];
|
||||
fwrite(&ThisCol,1,sizeof(u16),File);
|
||||
}
|
||||
return(Pos);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
int CMkActor::WriteAnimList()
|
||||
{
|
||||
int Pos=ftell(File);
|
||||
int i,ListSize=AnimList.size();
|
||||
vector<sSpriteAnim> Out;
|
||||
|
||||
// Write Dummy Hdrs
|
||||
FileHdr.AnimCount=ListSize;
|
||||
Out.resize(ListSize);
|
||||
for (i=0; i<ListSize; i++)
|
||||
{
|
||||
fwrite(&Out[i],1,sizeof(sSpriteAnim),File);
|
||||
}
|
||||
// Write Frame Lists
|
||||
for (i=0; i<ListSize; i++)
|
||||
{
|
||||
sAnim &ThisAnim=AnimList[i];
|
||||
sSpriteAnim &ThisOut=Out[i];
|
||||
|
||||
int f,FrameCount=ThisAnim.Frames.size();
|
||||
ThisOut.FrameCount=FrameCount;
|
||||
ThisOut.Anim=(u16*)ftell(File);
|
||||
for (f=0; f<FrameCount; f++)
|
||||
{
|
||||
sFrame &ThisFrame=ThisAnim.Frames[f];
|
||||
u16 FrameNo=ThisFrame.FrameIdx;
|
||||
fwrite(&FrameNo,1,sizeof(u16),File);
|
||||
}
|
||||
}
|
||||
int SavePos=ftell(File);
|
||||
|
||||
fseek(File,Pos,SEEK_SET);
|
||||
// ReWrite Headers
|
||||
for (i=0; i<ListSize; i++)
|
||||
{
|
||||
fwrite(&Out[i],1,sizeof(sSpriteAnim),File);
|
||||
}
|
||||
|
||||
fseek(File,SavePos,SEEK_SET);
|
||||
return(Pos);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
int CMkActor::WriteFrameList()
|
||||
{
|
||||
int Pos=ftell(File);
|
||||
int i,ListSize=BmpList.size();
|
||||
vector<sSpriteFrame> Out;
|
||||
|
||||
// Write Dummy Hdrs
|
||||
FileHdr.FrameCount=ListSize;
|
||||
Out.resize(ListSize);
|
||||
for (i=0; i<ListSize; i++)
|
||||
{
|
||||
fwrite(&Out[i],1,sizeof(sSpriteFrame),File);
|
||||
}
|
||||
// Write Frame Lists
|
||||
for (i=0; i<ListSize; i++)
|
||||
{
|
||||
sBmp &ThisBmp=BmpList[i];
|
||||
if (ThisBmp.VRamFlag)
|
||||
{ // VRam
|
||||
Out[i].PAKSpr=0;
|
||||
}
|
||||
else
|
||||
{ // Pak
|
||||
Out[i].PAKSpr=(u8*)ftell(File);
|
||||
fwrite(ThisBmp.Pak,1,ThisBmp.PakSize,File);
|
||||
PadFile(File);
|
||||
}
|
||||
|
||||
}
|
||||
int SavePos=ftell(File);
|
||||
|
||||
fseek(File,Pos,SEEK_SET);
|
||||
// ReWrite Headers
|
||||
for (i=0; i<ListSize; i++)
|
||||
{
|
||||
fwrite(&Out[i],1,sizeof(sSpriteFrame),File);
|
||||
}
|
||||
|
||||
fseek(File,SavePos,SEEK_SET);
|
||||
return(Pos);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
void CMkActor::WriteInclude()
|
||||
{
|
||||
GString Filename=IncFile+"_Anim.h";
|
||||
|
||||
File=fopen(Filename,"wt");
|
||||
|
||||
fprintf(File,"// %s Anim Header\n",Name);
|
||||
fprintf(File,"\n");
|
||||
fprintf(File,"#ifndef\t__ANIM_%s_HEADER__\n",Name);
|
||||
fprintf(File,"#define\t__ANIM_%s_HEADER__\n",Name);
|
||||
fprintf(File,"\n");
|
||||
fprintf(File,"\n");
|
||||
fprintf(File,"enum\tANIM_%s_LIST\n",Name);
|
||||
fprintf(File,"{\n");
|
||||
|
||||
int ListSize=AnimList.size();
|
||||
for (int i=0; i<ListSize; i++)
|
||||
{
|
||||
sAnim &ThisAnim=AnimList[i];
|
||||
GString AnimName=ThisAnim.Name;
|
||||
AnimName.Upper();
|
||||
fprintf(File,"\tANIM_%s_%s",Name,AnimName);
|
||||
if (i==0)
|
||||
{
|
||||
fprintf(File,"=0");
|
||||
}
|
||||
fprintf(File,",\n");
|
||||
}
|
||||
|
||||
fprintf(File,"\tNUM_ANIM_%s\n",Name);
|
||||
fprintf(File,"};\n");
|
||||
fprintf(File,"\n");
|
||||
fprintf(File,"#endif\n");
|
||||
|
||||
fclose(File);
|
||||
}
|
94
Utils/MkActor/MkActor.dsp
Normal file
94
Utils/MkActor/MkActor.dsp
Normal file
|
@ -0,0 +1,94 @@
|
|||
# Microsoft Developer Studio Project File - Name="MkActor" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=MkActor - 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 "MkActor.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 "MkActor.mak" CFG="MkActor - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "MkActor - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "MkActor - 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)" == "MkActor - 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 "..\libs\glib" /I "..\libs\maths" /I "..\libs\davelib" /I "..\libs\ginlib" /I "..\libs\texgrab" /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 glib.lib ginlib.lib texgrab.lib maths.lib davelib.lib /nologo /subsystem:console /machine:I386 /out:"..\..\tools\data\bin\MkActor.exe" /libpath:"..\libs\psxlib\release" /libpath:"..\libs\ginlib\release" /libpath:"..\libs\glib\release" /libpath:"..\libs\davelib\release" /libpath:"..\libs\texgrab\release" /libpath:"..\libs\maths\release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "MkActor - 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 /MDd /W3 /Gm /Gi /GX /ZI /Od /I "..\libs\glib" /I "..\libs\maths" /I "..\libs\davelib" /I "..\libs\ginlib" /I "..\libs\texgrab" /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 glib.lib ginlib.lib texgrab.lib maths.lib davelib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\libs\psxlib\debug" /libpath:"..\libs\ginlib\debug" /libpath:"..\libs\glib\debug" /libpath:"..\libs\davelib\debug" /libpath:"..\libs\texgrab\debug" /libpath:"..\libs\maths\debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "MkActor - Win32 Release"
|
||||
# Name "MkActor - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MkActor.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MkActor.h
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
81
Utils/MkActor/MkActor.h
Normal file
81
Utils/MkActor/MkActor.h
Normal file
|
@ -0,0 +1,81 @@
|
|||
/*************************/
|
||||
/*** Actor Sprite Tool ***/
|
||||
/*************************/
|
||||
|
||||
#include <Vector3.h>
|
||||
#include <List.h>
|
||||
|
||||
//***************************************************************************
|
||||
struct sFrame
|
||||
{
|
||||
GString Filename;
|
||||
int FrameIdx;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
struct sAnim
|
||||
{
|
||||
GString Name;
|
||||
vector<sFrame> Frames;
|
||||
bool VRamFlag;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
struct sBmp
|
||||
{
|
||||
GString Filename;
|
||||
Frame Bmp;
|
||||
int ChkR,ChkG,ChkB;
|
||||
u8 *RGB;
|
||||
u8 *Psx;
|
||||
u8 *Pak;
|
||||
int PsxSize;
|
||||
int PakSize;
|
||||
bool VRamFlag;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
class CMkActor
|
||||
{
|
||||
public:
|
||||
CMkActor(GString &ActorName,GString &ActorPath,GString &SpritePath);
|
||||
// ~CMkActor();
|
||||
|
||||
static void SetTPData(const char *Name,int TPBase,int TPW,int TPH);
|
||||
|
||||
void Load();
|
||||
void Process();
|
||||
void Write();
|
||||
void CleanUp();
|
||||
|
||||
private:
|
||||
void ReadScript(const char *Filename,vector<GString> &List);
|
||||
void BuildFrameList();
|
||||
void FindFrames(sAnim &ThisAnim);
|
||||
|
||||
void LoadFrameList();
|
||||
void LoadFrame(sFrame &ThisFrame,bool VRamFlag);
|
||||
int LoadBmp(GString &Name,bool VRamFlag);
|
||||
bool IsImageSame(sBmp &Bmp0,sBmp &Bmp1);
|
||||
void MakePsxGfx(sBmp &Bmp);
|
||||
void ProcessFrames();
|
||||
|
||||
int WritePalette();
|
||||
int WriteAnimList();
|
||||
int WriteFrameList();
|
||||
|
||||
void WriteInclude();
|
||||
GString Name,ActorDir,SpriteDir;
|
||||
GString OutFile,IncFile;
|
||||
|
||||
FILE *File;
|
||||
sSpriteAnimBank FileHdr;
|
||||
|
||||
vector<GString> InAnimList;
|
||||
vector<sAnim> AnimList;
|
||||
vector<sBmp> BmpList;
|
||||
CTexGrab TexGrab;
|
||||
int DupCount;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
Loading…
Add table
Reference in a new issue