This commit is contained in:
Daveo 2001-04-01 20:22:49 +00:00
parent 1966aa6f60
commit 2b171295b5
44 changed files with 588 additions and 603 deletions

View file

@ -47,6 +47,7 @@ int round(float f)
}
//***************************************************************************
/*
void alignFile( FILE *f, int align )
{
long fp = ftell(f);
@ -57,6 +58,17 @@ void alignFile( FILE *f, int align )
fwrite(buffer, s, 1, f);
}
}
*/
//***************************************************************************
void PadFile(FILE *File)
{
int Pad=ftell(File) & 3;
if (Pad)
{
fwrite(&Pad,Pad,1,File);
}
}
//***************************************************************************
GString CheckFileString(const char * Str)
@ -148,3 +160,58 @@ FILE *File=fopen(Name,"rb");
}
return((char*)Name);
}
/**************************************************************************************/
struct sTgaHdr
{
char id; // 0
char colmaptype; // 1
char imagetype; // 2
char fei[2]; // 3
char cml[2]; // 5
char cmes; // 7
short xorig; // 8
short yorig; // 10
short width; // 12
short height; // 14
char depth; // 15
char imagedesc; // 16
};
void SaveTGA(char *Filename,int W,int H,u8 *Data,bool IsBGR)
{
FILE *File;
sTgaHdr FileHdr;
File=fopen(Filename,"wb");
memset(&FileHdr,0 ,sizeof(sTgaHdr));
FileHdr.imagetype= 2; //imagetype
FileHdr.width = W;
FileHdr.height= H;
FileHdr.depth=24;
fwrite(&FileHdr,sizeof(sTgaHdr),1,File);
if (!IsBGR)
{
fwrite(Data,W*H*3,1,File);
}
else
{
int Size=W*H;
for (int i=0; i<Size;i++)
{
fwrite(&Data[2],1,1,File);
fwrite(&Data[1],1,1,File);
fwrite(&Data[0],1,1,File);
Data+=3;
}
}
fclose(File);
}
//***************************************************

View file

@ -100,6 +100,10 @@ SOURCE=.\facestore.h
# End Source File
# Begin Source File
SOURCE=.\IniClass.h
# End Source File
# Begin Source File
SOURCE=.\List.h
# End Source File
# Begin Source File

View file

@ -66,9 +66,12 @@ void DebugStr();
int round(float f);
void alignFile( FILE *f, int align );
//void alignFile( FILE *f, int align );
void PadFile(FILE *File);
char *FindFile(const char *Name);
void SaveTGA(char *Filename,int W,int H,u8 *Data,bool IsBGR=false);
//***************************************************************************
#endif

View file

@ -127,7 +127,7 @@ void Export(char *OutFile)
}
/*----------------------------------------------------------------------------*/
char *GetData(char *GroupEntry,char *KeyEntry)
char *GetData(const char *GroupEntry,const char *KeyEntry)
{
int Group=FindGroup(GroupEntry);
if (Group==-1) return(0);
@ -138,14 +138,14 @@ int Entry=FindKey(GroupEntry,KeyEntry);
}
/*----------------------------------------------------------------------------*/
char *GetStr(char *GroupEntry,char *KeyEntry)
char *GetStr(const char *GroupEntry,const char *KeyEntry)
{
char *Str=GetData(GroupEntry,KeyEntry);
return(Str);
}
/*----------------------------------------------------------------------------*/
int GetInt(char *GroupEntry,char *KeyEntry)
int GetInt(const char *GroupEntry,const char *KeyEntry)
{
char *Str=GetData(GroupEntry,KeyEntry);
int Var=0;
@ -153,6 +153,15 @@ int Var=0;
return(Var);
}
/*----------------------------------------------------------------------------*/
bool GetInt(const char *GroupEntry,const char *KeyEntry,int &Var)
{
char *Str=GetData(GroupEntry,KeyEntry);
if (!Str) return(false);
Var=atol(Str);
return(true);
}
/*----------------------------------------------------------------------------*/
int UpdateGroup(char *GroupEntry)
{
@ -241,7 +250,7 @@ void StripGroupName(char *Name)
}
/*----------------------------------------------------------------------------*/
int FindGroup(char *GroupEntry)
int FindGroup(const char *GroupEntry)
{
for (int Loop=0;Loop<IniGroup.size();Loop++)
{
@ -251,7 +260,7 @@ int FindGroup(char *GroupEntry)
}
/*----------------------------------------------------------------------------*/
int FindKey(char *GroupEntry,char *KeyEntry)
int FindKey(const char *GroupEntry,const char *KeyEntry)
{
int Group=FindGroup(GroupEntry);;
if (Group==-1) return(-1);

View file

@ -846,7 +846,11 @@ void SprSet::WriteSprFile(char const * Name)
---------------------------------------------------------------------- */
void SprFrame::SetFrameAndInfo(Frame const & Fr,FileInfo const & NewMyFileInfo,int MaxSize)
{
Frame::CopyFrame(Fr);
if (this!=&Fr)
{
Frame::CopyFrame(Fr);
}
MyFileInfo=NewMyFileInfo;
OrigW=Fr.GetWidth();

View file

@ -110,12 +110,12 @@ BOOL operator==(sExpMapElem const &v1)
/*****************************************************************************/
/*** Things ******************************************************************/
/*****************************************************************************/
struct sExpLayerActor
struct sExpLayerThing
{
int Speed;
int TurnRate;
int Health;
int AttackStrength;
int Speed;
int TurnRate;
bool CollisionFlag;
bool PlayerFlag;
int Spare[8];

View file

@ -131,26 +131,3 @@ void CLayerActor::GUIChanged(CCore *Core)
}
}
/*****************************************************************************/
/*** Functions ***************************************************************/
/*****************************************************************************/
void CLayerActor::ExportThing(CExport &Exp,sLayerThing &ThisThing)
{
int i,ListSize=ThisThing.XY.size();
sExpLayerActor OutThing;
// Point List
Exp.Write(&ListSize,sizeof(int));
for (i=0 ;i<ListSize; i++)
{
Exp.Write(&ThisThing.XY[i],sizeof(CPoint));
}
// Thing
OutThing.Health=ThisThing.Data.Health;
OutThing.AttackStrength=ThisThing.Data.AttackStrength;
OutThing.Speed=ThisThing.Data.Speed;
OutThing.TurnRate=ThisThing.Data.TurnRate;
OutThing.CollisionFlag=ThisThing.Data.CollisionFlag;
OutThing.PlayerFlag=ThisThing.Data.PlayerFlag;
Exp.Write(&OutThing,sizeof(sExpLayerActor));
}

View file

@ -31,9 +31,6 @@ public:
void GUIThingUpdate(bool OnlySel=false);
void GUIThingPointUpdate(bool OnlySel=false);
void ExportThing(CExport &Exp,sLayerThing &ThisThing);
protected:
CGUILayerActor GUI;

View file

@ -114,27 +114,3 @@ void CLayerItem::GUIChanged(CCore *Core)
{
}
/*****************************************************************************/
/*** Functions ***************************************************************/
/*****************************************************************************/
void CLayerItem::ExportThing(CExport &Exp,sLayerThing &ThisThing)
{
/*
int i,ListSize=ThisThing.XY.size();
sExpLayerItem OutThing;
// Point List
Exp.Write(&ListSize,sizeof(int));
for (i=0 ;i<ListSize; i++)
{
Exp.Write(&ThisThing.XY[i],sizeof(CPoint));
}
// Thing
OutThing.Health=ThisThing.Data.Health;
OutThing.AttackStrength=ThisThing.Data.AttackStrength;
OutThing.Speed=ThisThing.Data.Speed;
OutThing.TurnRate=ThisThing.Data.TurnRate;
OutThing.CollisionFlag=ThisThing.Data.CollisionFlag;
OutThing.PlayerFlag=ThisThing.Data.PlayerFlag;
Exp.Write(&OutThing,sizeof(sExpLayerItem));
*/
}

View file

@ -30,9 +30,6 @@ public:
void GUIThingDefClear();
void GUIThingUpdate(bool OnlySel=false);
void ExportThing(CExport &Exp,sLayerThing &ThisThing);
protected:
CGUILayerItem GUI;

View file

@ -136,27 +136,3 @@ void CLayerPlatform::GUIChanged(CCore *Core)
*/
}
/*****************************************************************************/
/*** Functions ***************************************************************/
/*****************************************************************************/
void CLayerPlatform::ExportThing(CExport &Exp,sLayerThing &ThisThing)
{
/*
int i,ListSize=ThisThing.XY.size();
sExpLayerPlatform OutThing;
// Point List
Exp.Write(&ListSize,sizeof(int));
for (i=0 ;i<ListSize; i++)
{
Exp.Write(&ThisThing.XY[i],sizeof(CPoint));
}
// Thing
OutThing.Health=ThisThing.Data.Health;
OutThing.AttackStrength=ThisThing.Data.AttackStrength;
OutThing.Speed=ThisThing.Data.Speed;
OutThing.TurnRate=ThisThing.Data.TurnRate;
OutThing.CollisionFlag=ThisThing.Data.CollisionFlag;
OutThing.PlayerFlag=ThisThing.Data.PlayerFlag;
Exp.Write(&OutThing,sizeof(sExpLayerPlatform));
*/
}

View file

@ -31,9 +31,6 @@ public:
void GUIThingUpdate(bool OnlySel=false);
void GUIThingPointUpdate(bool OnlySel=false);
void ExportThing(CExport &Exp,sLayerThing &ThisThing);
protected:
// CGUILayerPlatform GUI;

View file

@ -701,6 +701,26 @@ int i,ListSize=ThingList.size();
ExportThingNames(Exp);
}
/*****************************************************************************/
void CLayerThing::ExportThing(CExport &Exp,sLayerThing &ThisThing)
{
int i,ListSize=ThisThing.XY.size();
sExpLayerThing OutThing;
// Point List
Exp.Write(&ListSize,sizeof(int));
for (i=0 ;i<ListSize; i++)
{
Exp.Write(&ThisThing.XY[i],sizeof(CPoint));
}
// Thing
OutThing.Health=ThisThing.Data.Health;
OutThing.AttackStrength=ThisThing.Data.AttackStrength;
OutThing.Speed=ThisThing.Data.Speed;
OutThing.TurnRate=ThisThing.Data.TurnRate;
OutThing.CollisionFlag=ThisThing.Data.CollisionFlag;
OutThing.PlayerFlag=ThisThing.Data.PlayerFlag;
Exp.Write(&OutThing,sizeof(sExpLayerThing));
}
/*****************************************************************************/
void CLayerThing::ExportThingNames(CExport &Exp)

View file

@ -78,7 +78,7 @@ virtual void SaveThingNames(CFile *File);
virtual void LoadThingScript(const char *Filename);
virtual void Export(CCore *Core,CExport &Exp);
virtual void ExportThing(CExport &Exp,sLayerThing &ThisThing)=0;
virtual void ExportThing(CExport &Exp,sLayerThing &ThisThing);
virtual void ExportThingNames(CExport &Exp);
// Functions

View file

@ -9,12 +9,14 @@
#include <vector>
#include <DaveLib.h>
#include <io.h>
#include <SprSet.h>
#include "MkActor.h"
#include <pak.h>
using namespace std;
//#define CheckDups 1
//#define OutputTGA
//***************************************************************************
vector<CMkActor> ActorList;
@ -257,6 +259,7 @@ int Error=0;
sFrame NewFrame;
NewFrame.Filename=Find.name;
ThisAnim.Frames.push_back(NewFrame);
Error=_findnext( FileHandle, &Find);
}
_findclose( FileHandle);
@ -283,7 +286,7 @@ int i,ListSize=AnimList.size();
//***************************************************************************
void CMkActor::LoadFrame(sFrame &ThisFrame,bool VRamFlag)
{
ThisFrame.FrameIdx=LoadBmp(ThisFrame.Filename,VRamFlag);
ThisFrame.FrameIdx=LoadBmp(ThisFrame.Filename,VRamFlag);
}
//***************************************************************************
@ -310,7 +313,7 @@ Rect OriginalRect;
nfAreaBytes=nfLineWidthBytes*nfH;
Bmp.PsxSize=nfAreaBytes;
Bmp.Psx=(u8*)malloc(nfAreaBytes);
Bmp.Psx=(u8*)malloc(nfAreaBytes+16);
ASSERT(Bmp.Psx);
for (int y=0;y<nfH;y++)
@ -324,7 +327,7 @@ Rect OriginalRect;
PixAddr=&Bmp.Psx[(x/2)+(nfLineWidthBytes*y)];
if (PixAddr>&Bmp.Psx[nfAreaBytes]) printf("!");
if (PixAddr>=&Bmp.Psx[nfAreaBytes]) ASSERT(!"");
if ((x&1))
{
*PixAddr&=0x0f;
@ -344,39 +347,28 @@ 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;
int BmpListSize=BmpList.size();
sBmp NewBmp;
SprFrame &NewFrame=NewBmp.Bmp;
FileInfo ThisInfo;
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);
// ThisInfo.SetInfo(name, CrossHair, ThisZeroColZero, MoveUVs, AllowRotate, ShrinkToFit, m_allocateAs16bit);
ThisInfo.SetInfo(Filename, false, true, false, false, true, false);
#if _DEBUG && 0
{
u8 *TGA=(u8*)malloc(Size*3);
ASSERT(TGA);
Bmp.FlipY();
Bmp.MakeRGB(TGA);
Bmp.FlipY();
NewBmp.RGB=0;
NewBmp.Pak=0;
NewBmp.Psx=0;
NewBmp.VRamFlag=VRamFlag;
char OutName[256];
sprintf(OutName,"\\x\\%s.tga",Name);
SaveTGA(OutName,W,H,TGA,true);
free(TGA);
}
#endif
NewFrame.LoadBMP(Filename);
#ifdef CheckDups
int Size=NewFrame.GetWidth()*NewFrame.GetHeight();
NewBmp.RGB=(u8*)malloc(Size*3);
ASSERT(NewBmp.RGB);
NewFrame.MakeRGB(NewBmp.RGB);
// Check for dups (Broken at the mo, ah well)
// Gen Chksum
u8 *RGB=NewBmp.RGB;
NewBmp.ChkR=NewBmp.ChkG=NewBmp.ChkB=0;
@ -386,15 +378,13 @@ u8 *RGB=NewBmp.RGB;
NewBmp.ChkG+=*RGB++;
NewBmp.ChkB+=*RGB++;
}
ListSize=BmpList.size();
Idx=-1;
int Idx=-1;
// Find existing
for (i=0; i<ListSize && Idx==-1; i++)
for (int i=0; i<BmpListSize && 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 (ThisBmp.ChkR==NewBmp.ChkR && ThisBmp.ChkG==NewBmp.ChkG && ThisBmp.ChkB==NewBmp.ChkB)
{
if (IsImageSame(ThisBmp,NewBmp)) Idx=i;
}
@ -406,23 +396,38 @@ u8 *RGB=NewBmp.RGB;
free(NewBmp.RGB);
return(Idx);
}
MakePsxGfx(NewBmp);
#endif
BmpList.push_back(NewBmp);
if (VRamFlag)
BmpList[BmpListSize].Bmp.SetFrameAndInfo(BmpList[BmpListSize].Bmp,ThisInfo,0);
MakePsxGfx(BmpList[BmpListSize]);
#if _DEBUG && defined(OutputTGA)
{
TexGrab.AddMemFrame(NewBmp.Filename,NewBmp.Bmp);
Frame &OutF=BmpList[BmpListSize].Bmp;
u8 *TGA=(u8*)malloc(OutF.GetWidth()*OutF.GetHeight()*3);
ASSERT(TGA);
OutF.FlipY();
OutF.MakeRGB(TGA);
OutF.FlipY();
char OutName[256];
sprintf(OutName,"\\x\\%s.tga",Name);
SaveTGA(OutName,OutF.GetWidth(),OutF.GetHeight(),TGA,true);
free(TGA);
}
return(ListSize);
#endif
return(BmpListSize);
}
//***************************************************************************
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 W0=Bmp0.Bmp.GetOrigW();
int H0=Bmp0.Bmp.GetOrigH();
int W1=Bmp1.Bmp.GetOrigW();
int H1=Bmp1.Bmp.GetOrigH();
int Size=W0*H0*3;
u8 *RGB0=Bmp0.RGB;
u8 *RGB1=Bmp1.RGB;
@ -436,6 +441,7 @@ u8 *RGB1=Bmp1.RGB;
}
return(true);
}
//***************************************************************************
//***************************************************************************
//***************************************************************************
@ -592,6 +598,11 @@ vector<sSpriteFrame> Out;
else
{ // Pak
Out[i].PAKSpr=(u8*)ftell(File);
Out[i].XOfs=-ThisBmp.Bmp.GetX();
Out[i].YOfs=-ThisBmp.Bmp.GetY();
Out[i].W=ThisBmp.Bmp.GetWidth();
Out[i].H=ThisBmp.Bmp.GetHeight();
fwrite(ThisBmp.Pak,1,ThisBmp.PakSize,File);
PadFile(File);
}

View file

@ -23,15 +23,14 @@ struct sAnim
//***************************************************************************
struct sBmp
{
GString Filename;
Frame Bmp;
int ChkR,ChkG,ChkB;
u8 *RGB;
u8 *Psx;
u8 *Pak;
int PsxSize;
int PakSize;
bool VRamFlag;
SprFrame Bmp;
int ChkR,ChkG,ChkB;
u8 *RGB;
u8 *Psx;
u8 *Pak;
int PsxSize;
int PakSize;
bool VRamFlag;
};
//***************************************************************************
@ -39,7 +38,6 @@ class CMkActor
{
public:
CMkActor(GString &ActorName,GString &ActorPath,GString &SpritePath);
// ~CMkActor();
static void SetTPData(const char *Name,int TPBase,int TPW,int TPH);