Moved modified HL SDK to trunk

This commit is contained in:
Scott Ehlert
2006-08-27 02:22:59 +00:00
parent 28c4ea4fec
commit 30235e05e5
900 changed files with 344676 additions and 0 deletions

View File

@ -0,0 +1,128 @@
# Microsoft Developer Studio Project File - Name="sprgen" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=sprgen - Win32 Release
!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 "sprgen.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 "sprgen.mak" CFG="sprgen - Win32 Release"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "sprgen - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "sprgen - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""$/SDKSrc/Tools/utils/sprgen", HVGBAAAA"
# PROP Scc_LocalPath "."
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "sprgen - 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 ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
# ADD CPP /nologo /W3 /GX /Zi /O1 /I "..\..\common" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /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 /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 /nologo /subsystem:console /debug /machine:I386
!ELSEIF "$(CFG)" == "sprgen - 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" /YX /c
# ADD CPP /nologo /Gm /GX /ZI /Od /I "..\..\common" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /FR /YX /FD /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /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 /nologo /subsystem:console /debug /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:console /debug /machine:I386
!ENDIF
# Begin Target
# Name "sprgen - Win32 Release"
# Name "sprgen - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90"
# Begin Source File
SOURCE=..\..\common\cmdlib.c
# End Source File
# Begin Source File
SOURCE=..\..\common\lbmlib.c
# End Source File
# Begin Source File
SOURCE=..\..\common\scriplib.c
# End Source File
# Begin Source File
SOURCE=..\sprgen.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
# Begin Source File
SOURCE=..\..\common\cmdlib.h
# End Source File
# Begin Source File
SOURCE=..\..\common\lbmlib.h
# End Source File
# Begin Source File
SOURCE=..\..\common\scriplib.h
# End Source File
# Begin Source File
SOURCE=..\spritegn.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@ -0,0 +1,37 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "sprgen"=.\sprgen.dsp - Package Owner=<4>
Package=<5>
{{{
begin source code control
"$/SDKSrc/Tools/utils/sprgen", HVGBAAAA
.
end source code control
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
begin source code control
"$/SDKSrc/Tools/utils/sprgen", HVGBAAAA
.
end source code control
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@ -0,0 +1,244 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="sprgen"
ProjectGUID="{8E8F8085-5C4F-4840-8581-62765A9FCF61}"
SccProjectName="&quot;$/SDKSrc/Tools/utils/sprgen&quot;, HVGBAAAA"
SccLocalPath=".">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="1"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\common"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
StringPooling="TRUE"
RuntimeLibrary="4"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Release/sprgen.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="3"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile=".\Release/sprgen.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\Release/sprgen.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Release/sprgen.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="1"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\common"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
RuntimeLibrary="5"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Debug/sprgen.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
BrowseInformation="1"
SuppressStartupBanner="TRUE"
DebugInformationFormat="3"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile=".\Debug/sprgen.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\Debug/sprgen.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Debug/sprgen.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90">
<File
RelativePath="..\..\common\cmdlib.c">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\common\lbmlib.c">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\common\scriplib.c">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\sprgen.c">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BrowseInformation="1"/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;fi;fd">
<File
RelativePath="..\..\common\cmdlib.h">
</File>
<File
RelativePath="..\..\common\lbmlib.h">
</File>
<File
RelativePath="..\..\common\scriplib.h">
</File>
<File
RelativePath="..\spritegn.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,333 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="sprgen"
ProjectGUID="{8E8F8085-5C4F-4840-8581-62765A9FCF61}"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Release/sprgen.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="1"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\common"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
PrecompiledHeaderFile=".\Release/sprgen.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile=".\Release/sprgen.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Release/sprgen.pdb"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Debug/sprgen.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\common"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
PrecompiledHeaderFile=".\Debug/sprgen.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
BrowseInformation="1"
SuppressStartupBanner="true"
DebugInformationFormat="3"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile=".\Debug/sprgen.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug/sprgen.pdb"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90"
>
<File
RelativePath="..\..\common\cmdlib.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="1"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BrowseInformation="1"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\common\lbmlib.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="1"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BrowseInformation="1"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\common\scriplib.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="1"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BrowseInformation="1"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\sprgen.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="1"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BrowseInformation="1"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;fi;fd"
>
<File
RelativePath="..\..\common\cmdlib.h"
>
</File>
<File
RelativePath="..\..\common\lbmlib.h"
>
</File>
<File
RelativePath="..\..\common\scriplib.h"
>
</File>
<File
RelativePath="..\spritegn.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

617
hlsdk/utils/sprgen/sprgen.c Normal file
View File

@ -0,0 +1,617 @@
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
****/
//
// spritegen.c: generates a .spr file from a series of .lbm frame files.
// Result is stored in /raid/quake/id1/sprites/<scriptname>.spr.
//
#pragma warning(disable : 4244) // type conversion warning.
#define INCLUDELIBS
#ifdef NeXT
#include <libc.h>
#endif
#include "spritegn.h"
#define MAX_BUFFER_SIZE 0x100000
#define MAX_FRAMES 1000
dsprite_t sprite;
byte *byteimage, *lbmpalette;
int byteimagewidth, byteimageheight;
byte *lumpbuffer = NULL, *plump;
char spritedir[1024];
char spriteoutname[1024];
int framesmaxs[2];
int framecount;
qboolean do16bit = true;
typedef struct {
spriteframetype_t type; // single frame or group of frames
void *pdata; // either a dspriteframe_t or group info
float interval; // only used for frames in groups
int numgroupframes; // only used by group headers
} spritepackage_t;
spritepackage_t frames[MAX_FRAMES];
void FinishSprite (void);
void Cmd_Spritename (void);
/*
============
WriteFrame
============
*/
void WriteFrame (FILE *spriteouthandle, int framenum)
{
dspriteframe_t *pframe;
dspriteframe_t frametemp;
pframe = (dspriteframe_t *)frames[framenum].pdata;
frametemp.origin[0] = LittleLong (pframe->origin[0]);
frametemp.origin[1] = LittleLong (pframe->origin[1]);
frametemp.width = LittleLong (pframe->width);
frametemp.height = LittleLong (pframe->height);
SafeWrite (spriteouthandle, &frametemp, sizeof (frametemp));
SafeWrite (spriteouthandle,
(byte *)(pframe + 1),
pframe->height * pframe->width);
}
/*
============
WriteSprite
============
*/
void WriteSprite (FILE *spriteouthandle)
{
int i, groupframe, curframe;
dsprite_t spritetemp;
sprite.boundingradius = sqrt (((framesmaxs[0] >> 1) *
(framesmaxs[0] >> 1)) +
((framesmaxs[1] >> 1) *
(framesmaxs[1] >> 1)));
//
// write out the sprite header
//
spritetemp.type = LittleLong (sprite.type);
spritetemp.texFormat = LittleLong (sprite.texFormat);
spritetemp.boundingradius = LittleFloat (sprite.boundingradius);
spritetemp.width = LittleLong (framesmaxs[0]);
spritetemp.height = LittleLong (framesmaxs[1]);
spritetemp.numframes = LittleLong (sprite.numframes);
spritetemp.beamlength = LittleFloat (sprite.beamlength);
spritetemp.synctype = LittleFloat (sprite.synctype);
spritetemp.version = LittleLong (SPRITE_VERSION);
spritetemp.ident = LittleLong (IDSPRITEHEADER);
SafeWrite (spriteouthandle, &spritetemp, sizeof(spritetemp));
if( do16bit )
{
// Write out palette in 16bit mode
short cnt = 256;
SafeWrite( spriteouthandle, (void *) &cnt, sizeof(cnt) );
SafeWrite( spriteouthandle, lbmpalette, cnt * 3 );
}
//
// write out the frames
//
curframe = 0;
for (i=0 ; i<sprite.numframes ; i++)
{
SafeWrite (spriteouthandle, &frames[curframe].type,
sizeof(frames[curframe].type));
if (frames[curframe].type == SPR_SINGLE)
{
//
// single (non-grouped) frame
//
WriteFrame (spriteouthandle, curframe);
curframe++;
}
else
{
int j, numframes;
dspritegroup_t dsgroup;
float totinterval;
groupframe = curframe;
curframe++;
numframes = frames[groupframe].numgroupframes;
//
// set and write the group header
//
dsgroup.numframes = LittleLong (numframes);
SafeWrite (spriteouthandle, &dsgroup, sizeof(dsgroup));
//
// write the interval array
//
totinterval = 0.0;
for (j=0 ; j<numframes ; j++)
{
dspriteinterval_t temp;
totinterval += frames[groupframe+1+j].interval;
temp.interval = LittleFloat (totinterval);
SafeWrite (spriteouthandle, &temp, sizeof(temp));
}
for (j=0 ; j<numframes ; j++)
{
WriteFrame (spriteouthandle, curframe);
curframe++;
}
}
}
}
/*
============
ExecCommand
============
*/
int cmdsrun;
void ExecCommand (char *cmd, ...)
{
int ret;
char cmdline[1024];
va_list argptr;
cmdsrun++;
va_start (argptr, cmd);
vsprintf (cmdline,cmd,argptr);
va_end (argptr);
// printf ("=============================================================\n");
// printf ("spritegen: %s\n",cmdline);
fflush (stdout);
ret = system (cmdline);
// printf ("=============================================================\n");
if (ret)
Error ("spritegen: exiting due to error");
}
/*
==============
LoadScreen
==============
*/
void LoadScreen (char *name)
{
static byte origpalette[256*3];
int iError;
printf ("grabbing from %s...\n",name);
iError = LoadBMP( name, &byteimage, &lbmpalette );
if (iError)
Error( "unable to load file \"%s\"\n", name );
byteimagewidth = bmhd.w;
byteimageheight = bmhd.h;
if (sprite.numframes == 0)
memcpy( origpalette, lbmpalette, sizeof( origpalette ));
else if (memcmp( origpalette, lbmpalette, sizeof( origpalette )) != 0)
{
Error( "bitmap \"%s\" doesn't share a pallette with the previous bitmap\n", name );
}
}
/*
===============
Cmd_Type
===============
*/
void Cmd_Type (void)
{
GetToken (false);
if (!strcmp (token, "vp_parallel_upright"))
sprite.type = SPR_VP_PARALLEL_UPRIGHT;
else if (!strcmp (token, "facing_upright"))
sprite.type = SPR_FACING_UPRIGHT;
else if (!strcmp (token, "vp_parallel"))
sprite.type = SPR_VP_PARALLEL;
else if (!strcmp (token, "oriented"))
sprite.type = SPR_ORIENTED;
else if (!strcmp (token, "vp_parallel_oriented"))
sprite.type = SPR_VP_PARALLEL_ORIENTED;
else
Error ("Bad sprite type\n");
}
/*
===============
Cmd_Texture
===============
*/
void Cmd_Texture (void)
{
GetToken (false);
if (!strcmp (token, "additive"))
sprite.texFormat = SPR_ADDITIVE;
else if (!strcmp (token, "normal"))
sprite.texFormat = SPR_NORMAL;
else if (!strcmp (token, "indexalpha"))
sprite.texFormat = SPR_INDEXALPHA;
else if (!strcmp (token, "alphatest"))
sprite.texFormat = SPR_ALPHTEST;
else
Error ("Bad sprite texture type\n");
}
/*
===============
Cmd_Beamlength
===============
*/
void Cmd_Beamlength ()
{
GetToken (false);
sprite.beamlength = atof (token);
}
/*
===============
Cmd_Load
===============
*/
void Cmd_Load (void)
{
GetToken (false);
LoadScreen (ExpandPathAndArchive(token));
}
/*
===============
Cmd_Frame
===============
*/
void Cmd_Frame ()
{
int x,y,xl,yl,xh,yh,w,h;
byte *screen_p, *source;
int linedelta;
dspriteframe_t *pframe;
int pix;
GetToken (false);
xl = atoi (token);
GetToken (false);
yl = atoi (token);
GetToken (false);
w = atoi (token);
GetToken (false);
h = atoi (token);
if ((xl & 0x07) || (yl & 0x07) || (w & 0x07) || (h & 0x07))
Error ("Sprite dimensions not multiples of 8\n");
if ((w > 256) || (h > 256))
Error ("Sprite has a dimension longer than 256");
xh = xl+w;
yh = yl+h;
pframe = (dspriteframe_t *)plump;
frames[framecount].pdata = pframe;
frames[framecount].type = SPR_SINGLE;
if (TokenAvailable ())
{
GetToken (false);
frames[framecount].interval = atof (token);
if (frames[framecount].interval <= 0.0)
Error ("Non-positive interval");
}
else
{
frames[framecount].interval = (float)0.1;
}
if (TokenAvailable ())
{
GetToken (false);
pframe->origin[0] = -atoi (token);
GetToken (false);
pframe->origin[1] = atoi (token);
}
else
{
pframe->origin[0] = -(w >> 1);
pframe->origin[1] = h >> 1;
}
pframe->width = w;
pframe->height = h;
if (w > framesmaxs[0])
framesmaxs[0] = w;
if (h > framesmaxs[1])
framesmaxs[1] = h;
plump = (byte *)(pframe + 1);
screen_p = byteimage + yl*byteimagewidth + xl;
linedelta = byteimagewidth - w;
source = plump;
for (y=yl ; y<yh ; y++)
{
for (x=xl ; x<xh ; x++)
{
pix = *screen_p;
*screen_p++ = 0;
// if (pix == 255)
// pix = 0;
*plump++ = pix;
}
screen_p += linedelta;
}
framecount++;
if (framecount >= MAX_FRAMES)
Error ("Too many frames; increase MAX_FRAMES\n");
}
/*
===============
Cmd_GroupStart
===============
*/
void Cmd_GroupStart (void)
{
int groupframe;
groupframe = framecount++;
frames[groupframe].type = SPR_GROUP;
frames[groupframe].numgroupframes = 0;
while (1)
{
GetToken (true);
if (endofscript)
Error ("End of file during group");
if (!strcmp (token, "$frame"))
{
Cmd_Frame ();
frames[groupframe].numgroupframes++;
}
else if (!strcmp (token, "$load"))
{
Cmd_Load ();
}
else if (!strcmp (token, "$groupend"))
{
break;
}
else
{
Error ("$frame, $load, or $groupend expected\n");
}
}
if (frames[groupframe].numgroupframes == 0)
Error ("Empty group\n");
}
/*
===============
ParseScript
===============
*/
void ParseScript (void)
{
while (1)
{
GetToken (true);
if (endofscript)
break;
if (!strcmp (token, "$load"))
{
Cmd_Load ();
}
if (!strcmp (token, "$spritename"))
{
Cmd_Spritename ();
}
else if (!strcmp (token, "$type"))
{
Cmd_Type ();
}
else if (!strcmp (token, "$texture"))
{
Cmd_Texture ();
}
else if (!strcmp (token, "$beamlength"))
{
Cmd_Beamlength ();
}
else if (!strcmp (token, "$sync"))
{
sprite.synctype = ST_SYNC;
}
else if (!strcmp (token, "$frame"))
{
Cmd_Frame ();
sprite.numframes++;
}
else if (!strcmp (token, "$load"))
{
Cmd_Load ();
}
else if (!strcmp (token, "$groupstart"))
{
Cmd_GroupStart ();
sprite.numframes++;
}
}
}
/*
==============
Cmd_Spritename
==============
*/
void Cmd_Spritename (void)
{
if (sprite.numframes)
FinishSprite ();
GetToken (false);
sprintf (spriteoutname, "%s%s.spr", spritedir, token);
memset (&sprite, 0, sizeof(sprite));
framecount = 0;
framesmaxs[0] = -9999999;
framesmaxs[1] = -9999999;
if ( !lumpbuffer )
lumpbuffer = malloc (MAX_BUFFER_SIZE * 2); // *2 for padding
if (!lumpbuffer)
Error ("Couldn't get buffer memory");
plump = lumpbuffer;
sprite.synctype = ST_RAND; // default
}
/*
==============
FinishSprite
==============
*/
void FinishSprite (void)
{
FILE *spriteouthandle;
if (sprite.numframes == 0)
Error ("no frames\n");
if (!strlen(spriteoutname))
Error ("Didn't name sprite file");
if ((plump - lumpbuffer) > MAX_BUFFER_SIZE)
Error ("Sprite package too big; increase MAX_BUFFER_SIZE");
spriteouthandle = SafeOpenWrite (spriteoutname);
printf ("saving in %s\n", spriteoutname);
WriteSprite (spriteouthandle);
fclose (spriteouthandle);
printf ("spritegen: successful\n");
printf ("%d frame(s)\n", sprite.numframes);
printf ("%d ungrouped frame(s), including group headers\n", framecount);
spriteoutname[0] = 0; // clear for a new sprite
}
/*
==============
main
==============
*/
extern char qproject[];
int main (int argc, char **argv)
{
int i;
printf( "sprgen.exe v 1.1 (%s)\n", __DATE__ );
printf ("----- Sprite Gen ----\n");
if (argc < 2 || argc > 7 )
Error ("usage: sprgen [-archive directory] [-no16bit] [-proj <project>] file.qc");
for( i=1; i<argc; i++ )
{
if( *argv[ i ] == '-' )
{
if( !strcmp( argv[ i ], "-archive" ) )
{
archive = true;
strcpy (archivedir, argv[i+1]);
printf ("Archiving source to: %s\n", archivedir);
i++;
}
else if( !strcmp( argv[ i ], "-proj" ) )
{
strcpy( qproject, argv[i+1] );
i++;
}
else if( !strcmp( argv[ i ], "-16bit" ) )
{
do16bit = true;
}
else if( !strcmp( argv[ i ], "-no16bit" ) )
{
do16bit = false;
}
else
{
printf( "Unsupported command line flag: '%s'", argv[i] );
}
}
else
break;
}
// SetQdirFromPath (argv[i]);
ExtractFilePath (argv[i], spritedir); // chop the filename
//
// load the script
//
LoadScriptFile (argv[i]);
ParseScript ();
FinishSprite ();
return 0;
}

View File

@ -0,0 +1,104 @@
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
****/
//
// spritegn.h: header file for sprite generation program
//
// **********************************************************
// * This file must be identical in the spritegen directory *
// * and in the Quake directory, because it's used to *
// * pass data from one to the other via .spr files. *
// **********************************************************
//-------------------------------------------------------
// This program generates .spr sprite package files.
// The format of the files is as follows:
//
// dsprite_t file header structure
// <repeat dsprite_t.numframes times>
// <if spritegroup, repeat dspritegroup_t.numframes times>
// dspriteframe_t frame header structure
// sprite bitmap
// <else (single sprite frame)>
// dspriteframe_t frame header structure
// sprite bitmap
// <endrepeat>
//-------------------------------------------------------
#ifdef INCLUDELIBS
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include "cmdlib.h"
#include "scriplib.h"
#include "lbmlib.h"
#endif
#define SPRITE_VERSION 2
// must match definition in modelgen.h
#ifndef SYNCTYPE_T
#define SYNCTYPE_T
typedef enum {ST_SYNC=0, ST_RAND } synctype_t;
#endif
// TODO: shorten these?
typedef struct {
int ident;
int version;
int type;
int texFormat;
float boundingradius;
int width;
int height;
int numframes;
float beamlength;
synctype_t synctype;
} dsprite_t;
#define SPR_VP_PARALLEL_UPRIGHT 0
#define SPR_FACING_UPRIGHT 1
#define SPR_VP_PARALLEL 2
#define SPR_ORIENTED 3
#define SPR_VP_PARALLEL_ORIENTED 4
#define SPR_NORMAL 0
#define SPR_ADDITIVE 1
#define SPR_INDEXALPHA 2
#define SPR_ALPHTEST 3
typedef struct {
int origin[2];
int width;
int height;
} dspriteframe_t;
typedef struct {
int numframes;
} dspritegroup_t;
typedef struct {
float interval;
} dspriteinterval_t;
typedef enum { SPR_SINGLE=0, SPR_GROUP } spriteframetype_t;
typedef struct {
spriteframetype_t type;
} dspriteframetype_t;
#define IDSPRITEHEADER (('P'<<24)+('S'<<16)+('D'<<8)+'I')
// little-endian "IDSP"