This commit is contained in:
Daveo 2000-12-06 19:29:40 +00:00
parent 2ba61e595c
commit 73c60fbd11
23 changed files with 471 additions and 84 deletions

View file

@ -0,0 +1,94 @@
# Microsoft Developer Studio Project File - Name="DaveLib" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=DaveLib - 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 "DaveLib.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 "DaveLib.mak" CFG="DaveLib - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "DaveLib - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "DaveLib - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "DaveLib - 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 ""
MTL=midl.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /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
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "DaveLib - 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 ""
MTL=midl.exe
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /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
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ENDIF
# Begin Target
# Name "DaveLib - Win32 Release"
# Name "DaveLib - Win32 Debug"
# Begin Source File
SOURCE=.\List.h
# End Source File
# Begin Source File
SOURCE=.\list2d.h
# End Source File
# End Target
# End Project

View file

@ -1,9 +1,11 @@
/**********************/
/*** Vtx List Class ***/
/**********************/
/******************/
/*** List Class ***/
/******************/
#if !defined __VTXLIST_CLASS_HEADER__
#define __VTXLIST_CLASS_HEADER__
#pragma warning( disable : 4786 )
#if !defined __LIST_CLASS_HEADER__
#define __LIST_CLASS_HEADER__
#include <Vector>
@ -41,10 +43,9 @@ public:
return(ListSize);
}
void clear()
{
List.clear();
}
void clear() {List.clear();}
void resize(int i) {List.resize(i);}
int size() {return(List.size());}

View file

@ -0,0 +1,10 @@
/******************/
/*** List Class ***/
/******************/
#include <Vector>
#include "List2d.h"

143
Utils/Libs/DaveLib/list2d.h Normal file
View file

@ -0,0 +1,143 @@
/*********************/
/*** List 2d Class ***/
/*********************/
#pragma warning( disable : 4786 )
#ifndef __LIST_2D_HEADER__
#define __LIST_2D_HEADER__
#include <Vector>
/*****************************************************************************/
template <class T> class CList2d
{
public:
inline int GetWidth()
{
return(List.size());
}
inline int GetHeight()
{
if (GetWidth())
{
return(List[0].size());
}
return(0);
}
inline void SetSize(int Width,int Height)
{
List.resize(Width);
for (int i=0;i<Width;i++)
{
List[i].resize(Height);
}
}
inline void Resize(int Width,int Height)
{
CList2d<T> Old=*this;
int OldWidth=Old.GetWidth();
int OldHeight=Old.GetHeight();
int MinW=min(Width,OldWidth);
int MinH=min(Height,OldHeight);
Delete();
SetSize(Width,Height,TRUE);
for (int Y=0; Y<MinH; Y++)
{
for (int X=0; X<MinW; X++)
{
Set(X,Y,Old.Get(X,Y));
}
}
}
inline void Delete()
{
int Width=GetWidth();
for (int i=0;i<Width;i++)
{
List[i].clear();
}
List.clear();
}
inline T &Get(int X,int Y)
{
return(List[X][Y]);
}
inline void Set(int X,int Y,T &Src)
{
int Width=GetWidth();
int Height=GetHeight();
// Make sure within List
if ((X>=0 && X<Width) && (Y>=0 && Y<Height))
{
List[X][Y]=Src;
}
}
inline void Set(int X,int Y,CList2d &Src)
{
int Width=Src.GetWidth();
int Height=Src.GetHeight();
for (int Y=0; Y<Height; Y++)
{
for (int X=0; X<Width; X++)
{
Set(StartX+X,StartY+Y,Src.Get(X,Y));
}
}
}
inline bool DoesContainElem(T &Tile)
{
int Width=GetWidth();
int Height=GetHeight();
for (int Y=0; Y<Height; Y++)
{
for (int X=0; X<Width; X++)
{
T &ThisElem=Get(X,Y);
if (ThisElem==Elem) return(TRUE);
}
}
return(FALSE);
}
inline void operator=(T &Src)
{
int Width=Src.GetWidth();
int Height=Src.GetHeight();
Delete();
SetSize(Width,Height);
for (int Y=0; Y<Height; Y++)
{
for (int X=0; X<Width; X++)
{
Set(X,Y,Src.Get(StartX+X,StartY+Y),Force);
}
}
}
protected:
std::vector< std::vector<T> > List;
};
/*****************************************************************************/
#endif

View file

@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Target_Dir ""
MTL=midl.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "include" /I "include\pc" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR"Release/" /Fp"Release/Glib.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR"Release/" /Fp"Release/Glib.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe

View file

@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Target_Dir ""
MTL=midl.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\glib\include" /I "..\glib\include\pc" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\glib" /I "..\maths" /I "..\davelib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe

View file

@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Target_Dir ""
MTL=midl.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\common" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe

View file

@ -65,8 +65,6 @@ CTexGrab::~CTexGrab()
---------------------------------------------------------------------- */
void CTexGrab::Process()
{
SprSet MySprSet;
MySprSet.setHalfTpage(m_useHalfTpage);
MySprSet.setAnimatedHeader(m_AnimatedHeadersOnly);
MySprSet.setDontOutputBoxes(m_DontOutputBoxes);
@ -92,6 +90,7 @@ SprSet MySprSet;
if (m_PagePlacements)
{
MySprSet.Write(m_OutFile,m_PageBase,m_WidthPages,m_HeightPages);
MySprSet.CreateTexInfo(TexInfo);
if (m_OutLbm)
MySprSet.WriteLBM(m_OutLbm);
@ -127,6 +126,14 @@ GString UpperName(Name);
Purpose:
Params:
---------------------------------------------------------------------- */
void CTexGrab::AddMemFrame(char *Name,Frame &Frame)
{
GString UpperName(Name);
UpperName.Upper();
MyFiles.AddMemFrame(UpperName,Frame);
}
/*

View file

@ -40,8 +40,9 @@ RSC=rc.exe
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
MTL=midl.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\GinLib" /I "..\glib\include" /I "..\glib\include\pc" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\glib" /I "..\ginlib" /I "..\maths" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe
@ -63,8 +64,9 @@ LIB32=link.exe -lib
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
MTL=midl.exe
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\GinLib" /I "..\glib\include" /I "..\glib\include\pc" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\glib" /I "..\ginlib" /I "..\maths" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /GZ /c
# ADD BASE RSC /l 0x809 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe

View file

@ -56,6 +56,8 @@ public:
~CTexGrab();
void AddFile(char *Name);
void AddMemFrame(char *Name,Frame &Frame);
void Process();
void CompressTpages(bool f) {m_compressTpages=f;}
@ -85,12 +87,15 @@ public:
void MaxSize(int Size) {MyFiles.SetMaxSize(Size);}
void SetTPage(int Base,int W,int H) {m_PageBase=Base; m_WidthPages=W; m_HeightPages=H; m_PagePlacements=true;}
void ForceOffsets(int XOfs,int YOfs) {MyFiles.SetXOff(XOfs); MyFiles.SetYOff(YOfs); MyFiles.SetForceOffsets(true);}
std::vector<sTexOutInfo> &GetTexInfo() {return(TexInfo);}
protected:
AllFiles MyFiles;
SprSet MySprSet;
GString m_OutFile;
GString m_OutLbm;
@ -109,6 +114,8 @@ protected:
bool m_AnimatedHeadersOnly;
bool m_DontOutputBoxes;
bool m_AlignHeaders;
std::vector<sTexOutInfo> TexInfo;
};

View file

@ -127,12 +127,19 @@ void SprSet::AddFile(FileInfo const & ThisInfo)
GString Ext(FileName.Ext());
Ext.Upper();
if (Ext == "LBM" || Ext == "BMP")
AddLbm(ThisInfo);
else if (Ext == "ANM")
AddAnm(ThisInfo);
if (ThisInfo.getHasMemFrame())
{ // NEW!! Frames from memory :o) Dave
AddFrame(ThisInfo.getMemFrame(),ThisInfo);
}
else
Error(ERR_FATAL,"Don't deal with these sort of files : %s", FileName.FullName());
{
if (Ext == "LBM" || Ext == "BMP")
AddLbm(ThisInfo);
else if (Ext == "ANM")
AddAnm(ThisInfo);
else
Error(ERR_FATAL,"Don't deal with these sort of files : %s", FileName.FullName());
}
}
/*----------------------------------------------------------------------
Function:
@ -355,6 +362,47 @@ void SprSet::WriteReport(char const * File)
Error(ERR_FATAL,"Couldn't open file %s for output",(char const *)OutFileName);
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
#include <direct.h>
void SprSet::CreateTexInfo(std::vector<sTexOutInfo> &TexInfo)
{
int ListSize=AllSprFrames.size();
const int DirLen=1024;
char Dir[DirLen+1];
GString CurrDir;
CurrDir=getcwd(Dir,DirLen);
CurrDir.Upper();
CurrDir=CurrDir+"\\";
TexInfo.resize(ListSize);
for (int f=0;f<ListSize;f++)
{
SprFrame &Frm =AllSprFrames[f];
sTexOutInfo &ThisInfo=TexInfo[f];
GString Name=Frm.GetFileInfo()->GetActualName();
ThisInfo.Name=GFName::makerelative(CurrDir,Name,Dir);
ThisInfo.Clut=Frm.GetClut();
ThisInfo.Tpage=Frm.GetTpage();
ThisInfo.Rotated=Frm.IsRotated();
ThisInfo.u=Frm.GetTPRect().X;
ThisInfo.v=Frm.GetTPRect().Y;
ThisInfo.w=Frm.GetWidth();
ThisInfo.h=Frm.GetHeight();
ThisInfo.XOfs=Frm.GetX();
ThisInfo.XOfs=Frm.GetY();
}
}
/*----------------------------------------------------------------------
Function:
Purpose: Allocate all processed frames into tpages

View file

@ -44,6 +44,15 @@
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
struct sTexOutInfo
{
GString Name;
u16 Clut;
u16 Tpage;
bool Rotated;
int u,v,w,h;
int XOfs,YOfs;
};
/* Encapsulates a file and all the infomation parkgrab needs to process it
----------------------------------------------------------------------- */
@ -54,7 +63,6 @@ class FileInfo
{
CrossHair=false;
ForceOffsets=false;
MemFrame=0;
}
FileInfo(FileInfo const & Fi)
@ -122,7 +130,10 @@ class FileInfo
ShrinkToFit=NewShrinkToFit;
m_allocateAs16Bit=allocateAs16Bit;
MemFrame=NewMemFrame;
if (NewMemFrame)
{
MemFrame=*NewMemFrame;
}
/*
if we're allocating on a 16 bit pixel boundary then
we don't want the texture to be rotated
@ -177,6 +188,12 @@ class FileInfo
bool getAllocateAs16Bit(void) const
{return(m_allocateAs16Bit);}
bool getHasMemFrame(void) const
{return(MemFrame.SeeData!=0);}
Frame const &getMemFrame() const
{return(MemFrame);}
char const * GetActualName(void) const
{return(ActualFileName);}
@ -198,7 +215,7 @@ class FileInfo
int XOff,YOff;
Frame *MemFrame;
Frame MemFrame;
};
typedef std::vector<FileInfo> FIVec;
@ -439,6 +456,26 @@ public:
{
return(MyFileInfo.getAllocateAs16Bit());
}
int getX(void) {return(X);}
int getY(void) {return(Y);}
int getW(void)
{
if (MyFileInfo.GetMoveUVs() && Width && !MyFileInfo.getAllocateAs16Bit())
return(Width-1);
else
return(Width);
}
int getH(void)
{
if (MyFileInfo.GetMoveUVs() && Height && !MyFileInfo.getAllocateAs16Bit())
return(Height-1);
else
return(Height);
}
protected:
void ResizeAndReduce(Frame & Frm,int TargCols,float XPerc,float YPerc,bool ZeroSeeThrough);
@ -485,6 +522,8 @@ public:
void AddFiles(FIVec const & FileList);
void CreateTexInfo(std::vector<sTexOutInfo> &TexInfo);
void Write(char const * FileName,int TpNumber,int WidthInTpages,int HeightInTpages);
void WriteLBM(char const * FileName);
void WriteSprFile(char const * Name);

View file

@ -55,15 +55,25 @@ struct TPInfo
/*----------------------------------------------------------------------
Vars
---- */
// changed by dave to get the pixel border back
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 */
{1,256,0,0}, // TP_4
{2,512,0,0}, // TP_8
{4,256,0,0}, // TP_16
{0,0,0,0}, // TP_SCREEN
{16*4,1024*4,0,0}, // TP_PAL
};
/*
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
------------------- */