This commit is contained in:
parent
bb0e21d8d6
commit
ab518ef2b9
5 changed files with 99 additions and 61 deletions
|
@ -29,7 +29,24 @@ GString OutPath;
|
||||||
GString IncludePath;
|
GString IncludePath;
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
void RepAlign(FILE *File,char *Txt=0)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
int Align=ftell(File)&3;
|
||||||
|
|
||||||
|
if (Align)
|
||||||
|
{
|
||||||
|
if (Txt)
|
||||||
|
printf("%s MisAlign %i\n",Txt,Align);
|
||||||
|
else
|
||||||
|
printf("%s MisAlign %i\n","File",Align);
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
PadFile(File);
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
char * CycleCommands(char *String,int Num)
|
char * CycleCommands(char *String,int Num)
|
||||||
{
|
{
|
||||||
char Text[2048],*TextPtr;
|
char Text[2048],*TextPtr;
|
||||||
|
@ -250,7 +267,7 @@ int Error=0;
|
||||||
Filename=SpriteDir+Name+"_"+ThisAnim.Name+"*.bmp";
|
Filename=SpriteDir+Name+"_"+ThisAnim.Name+"*.bmp";
|
||||||
if( (FileHandle= _findfirst( Filename, &Find)) == -1L )
|
if( (FileHandle= _findfirst( Filename, &Find)) == -1L )
|
||||||
{
|
{
|
||||||
printf( "No files in current directory!\n" );
|
GObject::Error(ERR_WARNING,"Cant find Anim %s.\n",ThisAnim.Name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,7 +303,7 @@ int i,ListSize=AnimList.size();
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
void CMkActor::LoadFrame(sFrame &ThisFrame,bool VRamFlag)
|
void CMkActor::LoadFrame(sFrame &ThisFrame,bool VRamFlag)
|
||||||
{
|
{
|
||||||
ThisFrame.FrameIdx=LoadBmp(ThisFrame.Filename,VRamFlag);
|
ThisFrame.FrameIdx=LoadBmp(ThisFrame.Filename,VRamFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
@ -361,6 +378,12 @@ FileInfo ThisInfo;
|
||||||
NewBmp.VRamFlag=VRamFlag;
|
NewBmp.VRamFlag=VRamFlag;
|
||||||
|
|
||||||
NewFrame.LoadBMP(Filename);
|
NewFrame.LoadBMP(Filename);
|
||||||
|
int ColorCount=NewFrame.GetNumOfCols();
|
||||||
|
if (ColorCount>16)
|
||||||
|
{
|
||||||
|
GObject::Error(ERR_WARNING,"%s has %i colors.\n",Name,ColorCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef CheckDups
|
#ifdef CheckDups
|
||||||
int Size=NewFrame.GetWidth()*NewFrame.GetHeight();
|
int Size=NewFrame.GetWidth()*NewFrame.GetHeight();
|
||||||
|
@ -486,17 +509,20 @@ void CMkActor::Write()
|
||||||
{
|
{
|
||||||
GString OutName=OutFile+".SBK";
|
GString OutName=OutFile+".SBK";
|
||||||
|
|
||||||
// printf("Writing %s\n",Name);
|
|
||||||
File=fopen(OutName,"wb");
|
File=fopen(OutName,"wb");
|
||||||
|
|
||||||
// Write Dummy Hdr
|
// Write Dummy Hdr
|
||||||
fwrite(&FileHdr,1,sizeof(sSpriteAnimBank),File);
|
fwrite(&FileHdr,1,sizeof(sSpriteAnimBank),File);
|
||||||
|
RepAlign(File,"MainHeader");
|
||||||
// Write Palette
|
// Write Palette
|
||||||
FileHdr.Palette=(u8*)WritePalette();
|
FileHdr.Palette=(u8*)WritePalette();
|
||||||
|
RepAlign(File,"PaletteHdr");
|
||||||
// Write AnimList
|
// Write AnimList
|
||||||
FileHdr.AnimList=(sSpriteAnim*)WriteAnimList();
|
FileHdr.AnimList=(sSpriteAnim*)WriteAnimList();
|
||||||
|
RepAlign(File,"AnimListHdr");
|
||||||
// Write FrameList
|
// Write FrameList
|
||||||
FileHdr.FrameList=(sSpriteFrame*)WriteFrameList();
|
FileHdr.FrameList=(sSpriteFrame*)WriteFrameList();
|
||||||
|
// RepAlign(File,"FrameHdr");
|
||||||
|
|
||||||
// Rewrite Header
|
// Rewrite Header
|
||||||
fseek(File, 0, SEEK_SET);
|
fseek(File, 0, SEEK_SET);
|
||||||
|
@ -520,6 +546,11 @@ vector<u16> OutPal;
|
||||||
PsxPalette.SetPlusColZero(true);
|
PsxPalette.SetPlusColZero(true);
|
||||||
|
|
||||||
Count=PsxPalette.GetNumOfCols();
|
Count=PsxPalette.GetNumOfCols();
|
||||||
|
if (Count<16) Count=16;
|
||||||
|
// if (Count>16)
|
||||||
|
// {
|
||||||
|
// GObject::Error(ERR_WARNING,"Too Many Colors.\n");
|
||||||
|
// }
|
||||||
FileHdr.ColorCount=Count;
|
FileHdr.ColorCount=Count;
|
||||||
PsxPalette.MakePSXPal(OutPal);
|
PsxPalette.MakePSXPal(OutPal);
|
||||||
for (i=0; i<Count; i++)
|
for (i=0; i<Count; i++)
|
||||||
|
@ -534,42 +565,46 @@ vector<u16> OutPal;
|
||||||
int CMkActor::WriteAnimList()
|
int CMkActor::WriteAnimList()
|
||||||
{
|
{
|
||||||
int Pos=ftell(File);
|
int Pos=ftell(File);
|
||||||
int i,ListSize=AnimList.size();
|
int i,AnimCount=AnimList.size();
|
||||||
vector<sSpriteAnim> Out;
|
vector<sSpriteAnim> Hdrs;
|
||||||
|
|
||||||
// Write Dummy Hdrs
|
// Write Dummy Hdrs
|
||||||
FileHdr.AnimCount=ListSize;
|
FileHdr.AnimCount=AnimCount;
|
||||||
Out.resize(ListSize);
|
Hdrs.resize(AnimCount);
|
||||||
for (i=0; i<ListSize; i++)
|
for (i=0; i<AnimCount; i++)
|
||||||
{
|
{
|
||||||
fwrite(&Out[i],1,sizeof(sSpriteAnim),File);
|
fwrite(&Hdrs[i],1,sizeof(sSpriteAnim),File);
|
||||||
}
|
}
|
||||||
|
RepAlign(File,"AnimListHdr");
|
||||||
|
|
||||||
// Write Frame Lists
|
// Write Frame Lists
|
||||||
for (i=0; i<ListSize; i++)
|
for (i=0; i<AnimCount; i++)
|
||||||
{
|
{
|
||||||
sAnim &ThisAnim=AnimList[i];
|
sAnim &ThisAnim=AnimList[i];
|
||||||
sSpriteAnim &ThisOut=Out[i];
|
|
||||||
|
|
||||||
int f,FrameCount=ThisAnim.Frames.size();
|
int f,FrameCount=ThisAnim.Frames.size();
|
||||||
ThisOut.FrameCount=FrameCount;
|
|
||||||
ThisOut.Anim=(u16*)ftell(File);
|
Hdrs[i].FrameCount=FrameCount;
|
||||||
|
Hdrs[i].Anim=(u16*)ftell(File);
|
||||||
|
|
||||||
for (f=0; f<FrameCount; f++)
|
for (f=0; f<FrameCount; f++)
|
||||||
{
|
{
|
||||||
sFrame &ThisFrame=ThisAnim.Frames[f];
|
sFrame &ThisFrame=ThisAnim.Frames[f];
|
||||||
u16 FrameNo=ThisFrame.FrameIdx;
|
u16 FrameNo=ThisFrame.FrameIdx;
|
||||||
fwrite(&FrameNo,1,sizeof(u16),File);
|
fwrite(&FrameNo,1,sizeof(u16),File);
|
||||||
}
|
}
|
||||||
}
|
RepAlign(File,"AnimIdx");
|
||||||
int SavePos=ftell(File);
|
|
||||||
|
}
|
||||||
|
|
||||||
fseek(File,Pos,SEEK_SET);
|
|
||||||
// ReWrite Headers
|
// ReWrite Headers
|
||||||
for (i=0; i<ListSize; i++)
|
int SavePos=ftell(File);
|
||||||
|
fseek(File,Pos,SEEK_SET);
|
||||||
|
for (i=0; i<AnimCount; i++)
|
||||||
{
|
{
|
||||||
fwrite(&Out[i],1,sizeof(sSpriteAnim),File);
|
fwrite(&Hdrs[i],1,sizeof(sSpriteAnim),File);
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek(File,SavePos,SEEK_SET);
|
fseek(File,SavePos,SEEK_SET);
|
||||||
|
|
||||||
return(Pos);
|
return(Pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -577,47 +612,49 @@ int SavePos=ftell(File);
|
||||||
int CMkActor::WriteFrameList()
|
int CMkActor::WriteFrameList()
|
||||||
{
|
{
|
||||||
int Pos=ftell(File);
|
int Pos=ftell(File);
|
||||||
int i,ListSize=BmpList.size();
|
int i,FrameCount=BmpList.size();
|
||||||
vector<sSpriteFrame> Out;
|
vector<sSpriteFrame> Hdrs;
|
||||||
|
|
||||||
// Write Dummy Hdrs
|
// Write Dummy Hdrs
|
||||||
FileHdr.FrameCount=ListSize;
|
FileHdr.FrameCount=FrameCount;
|
||||||
Out.resize(ListSize);
|
Hdrs.resize(FrameCount);
|
||||||
for (i=0; i<ListSize; i++)
|
for (i=0; i<FrameCount; i++)
|
||||||
{
|
{
|
||||||
fwrite(&Out[i],1,sizeof(sSpriteFrame),File);
|
fwrite(&Hdrs[i],1,sizeof(sSpriteFrame),File);
|
||||||
}
|
}
|
||||||
|
RepAlign(File,"FrameListHdr");
|
||||||
|
|
||||||
// Write Frame Lists
|
// Write Frame Lists
|
||||||
for (i=0; i<ListSize; i++)
|
for (i=0; i<FrameCount; i++)
|
||||||
{
|
{
|
||||||
sBmp &ThisBmp=BmpList[i];
|
sBmp &ThisBmp=BmpList[i];
|
||||||
if (ThisBmp.VRamFlag)
|
if (ThisBmp.VRamFlag)
|
||||||
{ // VRam
|
{ // VRam
|
||||||
Out[i].PAKSpr=0;
|
GObject::Error(ERR_FATAL,"VRam sprites not supported yet (%s)\n",ThisBmp.Bmp.GetName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Pak
|
{ // Pak
|
||||||
Out[i].PAKSpr=(u8*)ftell(File);
|
int XOfs=ThisBmp.Bmp.GetX()-(ThisBmp.Bmp.GetOrigW()/2);
|
||||||
Out[i].XOfs=-ThisBmp.Bmp.GetX();
|
int YOfs=ThisBmp.Bmp.GetY()-(ThisBmp.Bmp.GetOrigH());
|
||||||
Out[i].YOfs=-ThisBmp.Bmp.GetY();
|
Hdrs[i].PAKSpr=(u8*)ftell(File);
|
||||||
Out[i].W=ThisBmp.Bmp.GetWidth();
|
Hdrs[i].XOfs=XOfs;
|
||||||
Out[i].H=ThisBmp.Bmp.GetHeight();
|
Hdrs[i].YOfs=YOfs;
|
||||||
|
Hdrs[i].W=ThisBmp.Bmp.GetWidth();
|
||||||
|
Hdrs[i].H=ThisBmp.Bmp.GetHeight();
|
||||||
fwrite(ThisBmp.Pak,1,ThisBmp.PakSize,File);
|
fwrite(ThisBmp.Pak,1,ThisBmp.PakSize,File);
|
||||||
PadFile(File);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
int SavePos=ftell(File);
|
|
||||||
|
|
||||||
fseek(File,Pos,SEEK_SET);
|
}
|
||||||
// ReWrite Headers
|
// ReWrite Headers
|
||||||
for (i=0; i<ListSize; i++)
|
int SavePos=ftell(File);
|
||||||
|
fseek(File,Pos,SEEK_SET);
|
||||||
|
for (i=0; i<FrameCount; i++)
|
||||||
{
|
{
|
||||||
fwrite(&Out[i],1,sizeof(sSpriteFrame),File);
|
fwrite(&Hdrs[i],1,sizeof(sSpriteFrame),File);
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek(File,SavePos,SEEK_SET);
|
fseek(File,SavePos,SEEK_SET);
|
||||||
|
|
||||||
return(Pos);
|
return(Pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -658,3 +695,4 @@ int ListSize=AnimList.size();
|
||||||
|
|
||||||
fclose(File);
|
fclose(File);
|
||||||
}
|
}
|
||||||
|
//
|
|
@ -99,6 +99,7 @@ RECT Rect;
|
||||||
Rect.y=TexY;
|
Rect.y=TexY;
|
||||||
Rect.w=FrameGfx->W/4;
|
Rect.w=FrameGfx->W/4;
|
||||||
Rect.h=FrameGfx->H;
|
Rect.h=FrameGfx->H;
|
||||||
|
|
||||||
LoadImage( &Rect, (u32*)CActorPool::UnpackBuffer);
|
LoadImage( &Rect, (u32*)CActorPool::UnpackBuffer);
|
||||||
|
|
||||||
POLY_FT4 *Ft4=GetPrimFT4();
|
POLY_FT4 *Ft4=GetPrimFT4();
|
||||||
|
@ -125,53 +126,54 @@ POLY_FT4 *Ft4=GetPrimFT4();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CActorGfx::SetUpFT4(POLY_FT4 *Ft4,sSpriteFrame *ThisFrame,int X,int Y,bool XFlip,bool YFlip)
|
void CActorGfx::SetUpFT4(POLY_FT4 *Ft4,sSpriteFrame *Frame,int X,int Y,bool XFlip,bool YFlip)
|
||||||
{
|
{
|
||||||
int U=0;
|
int U=0;
|
||||||
int V=4;
|
int V=4;
|
||||||
int W=ThisFrame->W;
|
int W=Frame->W;
|
||||||
int H=ThisFrame->H;
|
int H=Frame->H;
|
||||||
|
|
||||||
if (XFlip)
|
if (XFlip)
|
||||||
{
|
{
|
||||||
|
X-=Frame->XOfs;
|
||||||
|
X-=W;
|
||||||
Ft4->u0=U+W-1;
|
Ft4->u0=U+W-1;
|
||||||
Ft4->u1=U;
|
Ft4->u1=U;//-1;
|
||||||
Ft4->u2=U+W-1;
|
Ft4->u2=U+W-1;
|
||||||
Ft4->u3=U;
|
Ft4->u3=U;//-1;
|
||||||
X-=ThisFrame->XOfs;
|
|
||||||
X-=ThisFrame->W;
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
X+=Frame->XOfs;
|
||||||
Ft4->u0=U;
|
Ft4->u0=U;
|
||||||
Ft4->u1=U+W;
|
Ft4->u1=U+W;
|
||||||
Ft4->u2=U;
|
Ft4->u2=U;
|
||||||
Ft4->u3=U+W;
|
Ft4->u3=U+W;
|
||||||
X+=ThisFrame->XOfs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (YFlip)
|
if (YFlip)
|
||||||
{
|
{
|
||||||
|
Y-=Frame->YOfs;
|
||||||
|
Y-=H;
|
||||||
Ft4->v0=V+H-1;
|
Ft4->v0=V+H-1;
|
||||||
Ft4->v1=V+H-1;
|
Ft4->v1=V+H-1;
|
||||||
Ft4->v2=V;
|
Ft4->v2=V;//-1;
|
||||||
Ft4->v3=V;
|
Ft4->v3=V;//-1;
|
||||||
Y-=ThisFrame->YOfs;
|
}
|
||||||
Y-=ThisFrame->H/2;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Y+=Frame->YOfs;
|
||||||
Ft4->v0=V;
|
Ft4->v0=V;
|
||||||
Ft4->v1=V;
|
Ft4->v1=V;
|
||||||
Ft4->v2=V+H;
|
Ft4->v2=V+H;
|
||||||
Ft4->v3=V+H;
|
Ft4->v3=V+H;
|
||||||
Y+=ThisFrame->YOfs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setXYWH(Ft4,X,Y,W,H);
|
setXYWH(Ft4,X,Y,W,H);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CActorGfx::Dump()
|
void CActorGfx::Dump()
|
||||||
{
|
{
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -196,9 +196,7 @@ struct sSpriteFrame
|
||||||
{
|
{
|
||||||
u8 *PAKSpr; // 4
|
u8 *PAKSpr; // 4
|
||||||
s8 XOfs,YOfs; // 2
|
s8 XOfs,YOfs; // 2
|
||||||
s8 HX,HY; // 2
|
|
||||||
u8 W,H; // 2
|
u8 W,H; // 2
|
||||||
u16 Pad;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sSpriteAnim
|
struct sSpriteAnim
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue