This commit is contained in:
parent
e2939015d9
commit
f7a92200db
4 changed files with 296 additions and 0 deletions
168
Utils/MkColTab/MkColTab.cpp
Normal file
168
Utils/MkColTab/MkColTab.cpp
Normal file
|
@ -0,0 +1,168 @@
|
|||
/*********************************/
|
||||
/*** Make Collision Table Util ***/
|
||||
/*********************************/
|
||||
|
||||
#include "stdio.h"
|
||||
#include <misc.hpp>
|
||||
#include <vector>
|
||||
#include <DaveLib.h>
|
||||
|
||||
#include "MkColTab.h"
|
||||
|
||||
//***************************************************************************
|
||||
char * CycleCommands(char *String,int Num)
|
||||
{
|
||||
if (String[0]=='-' || String[0]=='/')
|
||||
{
|
||||
// Check Format
|
||||
switch (String[1])
|
||||
{// Switches
|
||||
case 'o':
|
||||
OutStr = CheckFileString(String);
|
||||
break;
|
||||
case 'd':
|
||||
DebugOn=true;
|
||||
break;
|
||||
default:
|
||||
GObject::Error(ERR_FATAL,"Unknown switch %s",String);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GString UpperName(String);
|
||||
UpperName.Upper();
|
||||
MyFiles.AddFile(UpperName);
|
||||
}
|
||||
|
||||
return(String);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
void Usage(char *ErrStr)
|
||||
{
|
||||
printf("\nMkColTab: by Dave\n");
|
||||
printf("Usage: nMkColTab <Col.Bmp> [ <file>.. ] [ switches.. ]\n");
|
||||
printf("Switches:\n");
|
||||
printf(" -o:[FILE] Set output File\n");
|
||||
printf(" -d Set Debug On\n");
|
||||
GObject::Error(ERR_FATAL,ErrStr);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
//***************************************************************************
|
||||
//***************************************************************************
|
||||
//***************************************************************************
|
||||
void CMkColTab::Load(const char*Name)
|
||||
{
|
||||
InFrame.LoadBMP(Name);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
void CMkColTab::Process()
|
||||
{
|
||||
int BlkW=InFrame.GetWidth()/BLK_SIZE;
|
||||
int BlkH=InFrame.GetHeight()/BLK_SIZE;
|
||||
Rect R;
|
||||
sColInfo ThisTile;
|
||||
|
||||
R.W=BLK_SIZE;
|
||||
R.H=BLK_SIZE;
|
||||
|
||||
ThisTile.Ofs.resize(BLK_SIZE);
|
||||
// Add Blank
|
||||
Tiles.push_back(ThisTile);
|
||||
|
||||
for (int BlkY=0; BlkY<BlkH; BlkY++)
|
||||
{
|
||||
for (int BlkX=0; BlkX<BlkW; BlkX++)
|
||||
{
|
||||
R.X=BlkX*BLK_SIZE;
|
||||
R.Y=BlkY*BLK_SIZE;
|
||||
|
||||
for (int F=0; F<4; F++)
|
||||
{
|
||||
Frame ThisFrame;
|
||||
// Cut and Flip Tile
|
||||
ThisFrame.Grab(InFrame,R);
|
||||
|
||||
if (F&1) ThisFrame.FlipX();
|
||||
if (!(F&2)) ThisFrame.FlipY(); // Loaded upside down!
|
||||
|
||||
if (DebugOn) printf("%i %i %i\n",BlkX,BlkY,F);
|
||||
BuildTable(ThisFrame,ThisTile);
|
||||
Tiles.push_back(ThisTile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
void CMkColTab::BuildTable(Frame &ThisFrame,sColInfo &ThisTile)
|
||||
{
|
||||
int X,Y;
|
||||
u8 c;
|
||||
|
||||
for (X=0; X<BLK_SIZE; X++)
|
||||
{
|
||||
c=-1;
|
||||
ThisTile.Ofs[X]=-1;
|
||||
for (Y=0; Y<BLK_SIZE && c; Y++)
|
||||
{
|
||||
c=ThisFrame.GetPixel(X,Y);
|
||||
if (c) ThisTile.Ofs[X]++;
|
||||
if (DebugOn) printf("%i",c);
|
||||
}
|
||||
if (DebugOn) printf("\t%i \n",ThisTile.Ofs[X]);
|
||||
}
|
||||
if (DebugOn) printf("\n");
|
||||
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
void CMkColTab::Write(const char *Filename)
|
||||
{
|
||||
int ListSize=Tiles.size();
|
||||
|
||||
if (DebugOn) printf("%i Tiles\n",ListSize);
|
||||
File=fopen(Filename,"wb");
|
||||
|
||||
for (int i=0; i<ListSize; i++)
|
||||
{
|
||||
sColInfo &ThisTile=Tiles[i];
|
||||
for (int X=0; X<BLK_SIZE; X++)
|
||||
{
|
||||
u8 c=ThisTile.Ofs[X];
|
||||
fwrite(&c,1,1,File);
|
||||
}
|
||||
}
|
||||
fclose(File);
|
||||
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
CMkColTab ColTab;
|
||||
CommandLine(argc,argv,CycleCommands);
|
||||
|
||||
std::vector<GString> const &Files = MyFiles.GetFileInfoVector();
|
||||
|
||||
if (!Files.size()) Usage("No Levels specified\n");
|
||||
if (Files.size()>1) Usage("Too many inputs\n");
|
||||
if (OutStr.Empty()) Usage("No Output specified\n");
|
||||
|
||||
|
||||
ColTab.Load(Files[0]);
|
||||
ColTab.Process();
|
||||
ColTab.Write(OutStr);
|
||||
|
||||
printf("Made %s\n",OutStr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
93
Utils/MkColTab/MkColTab.dsp
Normal file
93
Utils/MkColTab/MkColTab.dsp
Normal file
|
@ -0,0 +1,93 @@
|
|||
# Microsoft Developer Studio Project File - Name="MkColTab" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=MkColTab - 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 "MkColTab.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 "MkColTab.mak" CFG="MkColTab - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "MkColTab - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "MkColTab - 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)" == "MkColTab - 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\psxlib" /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 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib davelib.lib glib.lib /nologo /subsystem:console /machine:I386 /out:"..\..\tools\data\bin\MkColTab.exe" /libpath:"..\libs\glib\release" /libpath:"..\libs\davelib\release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "MkColTab - 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 "..\libs\glib" /I "..\libs\maths" /I "..\libs\davelib" /I "..\libs\ginlib" /I "..\libs\psxlib" /I "..\libs\texgrab" /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 davelib.lib glib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\libs\ginlib\debug" /libpath:"..\libs\glib\debug" /libpath:"..\libs\davelib\debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "MkColTab - Win32 Release"
|
||||
# Name "MkColTab - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MkColTab.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MkColTab.h
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
35
Utils/MkColTab/MkColTab.h
Normal file
35
Utils/MkColTab/MkColTab.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*********************************/
|
||||
/*** Make Collision Table Util ***/
|
||||
/*********************************/
|
||||
|
||||
#ifndef __MKCOLTAB_HEADER__
|
||||
#define __MKCOLTAB_HEADER__
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct sColInfo
|
||||
{
|
||||
vector<s8> Ofs;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
class CMkColTab
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
BLK_SIZE=16,
|
||||
};
|
||||
void Load(const char *Filename);
|
||||
void Process();
|
||||
void Write(const char *Filename);
|
||||
|
||||
protected:
|
||||
void BuildTable(Frame &ThisFrame,sColInfo &ThisTile);
|
||||
|
||||
Frame InFrame;
|
||||
vector<sColInfo> Tiles;
|
||||
FILE *File;
|
||||
};
|
||||
|
||||
#endif
|
BIN
tools/Data/bin/MkColTab.exe
Normal file
BIN
tools/Data/bin/MkColTab.exe
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue