Tool used to convert DOS LPF files to UQM .ani + presentations

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1477 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2005-01-21 18:42:28 +00:00
parent 7e80ee001d
commit c92033fe37
6 changed files with 1674 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
########################################################################
# This is a GNU makefile - tested on CYGWIN and Linux
#
# You may need to compile or install libpng and/or zlib before
# compiling this.
#
TARGET = lpf2ani
# These flags are needed to get it to compile with libpngX.dll on CYGWIN
# CYGWINFLAGS = -DPNG_USE_DLL
CYGWINFLAGS =
PNGFLAGS = -I.
CC = gcc
CFLAGS = -W -Wall -O0 # -g
LIBS = -L/usr/local/lib -lpng -lm -lz
LDFLAGS=
BINS = $(TARGET) $(TARGET).exe
SRCS = lpf2ani.c
OBJS = lpf2ani.o
.SUFFIXES: .c .o
.c.o:
$(CC) -c $(CFLAGS) -o $@ $*.c $(PNGFLAGS) $(CYGWINFLAGS)
all: $(TARGET)
$(TARGET): $(OBJS)
$(CC) -o $(TARGET) $(OBJS) $(LIBS) $(LDFLAGS)
clean:
rm -f $(BINS) *.o
+15
View File
@@ -0,0 +1,15 @@
/* Dummy compile-time configuration options
* Only used when compiling in MS VC++ using UQM's getopt.c
*/
#ifndef _CONFIG_H
#define _CONFIG_H
/* Define if words are stored with the most significant byte first */
#undef WORDS_BIGENDIAN
/* Defined if your system has getopt.h */
#undef HAVE_GETOPT_H
#endif /* _CONFIG_H */
+161
View File
@@ -0,0 +1,161 @@
#include <stdint.h>
#if defined(_MSC_VER)
# define PACKED
# pragma pack(push, 1)
#elif defined(__GNUC__)
# define PACKED __attribute__ ((packed))
#endif
// LPF file layout
//
// header (0x40)
// padding (?)
// palette (0x400) - get offset from header
// 4 bytes/color)
// usually 0x100 colors
// framepackinfos (?) - get offset from header
// get number if packs from header
// 1st pack
// immediatelly follows framepackinfos
// 2nd pack
// offset = offset(1st pack) + 0x10000
// ...
// last pack
// end
typedef struct
{
uint32_t PACKED magic; // "LPF "
uint16_t PACKED cpackslots; // frame-pack slots
uint16_t PACKED cpacks; // frame-pack count
uint32_t PACKED cframes; // frame count
uint16_t PACKED opal; // offset of palette
uint16_t PACKED opacks; // offset of framepack infos
uint32_t PACKED type; // "ANIM"
uint16_t PACKED w; // animation width
uint16_t PACKED h; // animation height
uint16_t PACKED stuff1[0x14]; // who knows?
uint32_t PACKED cframes2; // again?
uint32_t PACKED fps; // frames/second
} header;
#define PAL_COLORS 0x100
typedef union
{
struct {
uint8_t b, g, r, a;
} bchan;
uint8_t channels[4];
uint32_t rgba;
} lpfpalcolor;
typedef struct
{
uint16_t PACKED frame; // first frame in this pack
uint16_t PACKED cframes; // count of frames in this pack
uint16_t PACKED datasize; // size of data in this pack
} framepackinfo;
typedef struct
{
framepackinfo PACKED info; // pack info
uint16_t PACKED za; // 0 word
uint16_t PACKED sizes[1]; // frame-size array
} framepack;
#define FRAMEPACK_SIZE(fpi) \
(sizeof(framepack) + sizeof(uint16_t) * (fpi.cframes - 1))
typedef struct
{
uint16_t PACKED flags; // 0x0042 - frame flags?
uint16_t PACKED csubs; // 0x0001 - count of subframes?
// packed frame data follows
} frameheader;
// Frame Data
// Everything is stored LSB first unless otherwise specified.
//
// The data is processed and dumped into the frame buffer linearly. If not
// all of the frame buffer is covered by the data packets, the remaining
// pixels are copied from the previous frame.
//
// Data Packet (typed packets follow and include the data described here):
// length meaning
// 1 type and count
// - bit 7: type flag (FD_EXT_FLAG)
// - bits 0-6: count
// flag=0:
// count=0: pixel repeat; Repeat Packet
// count=N: quote next N; Quote Packet
// flag=1:
// count=0: 16-bit counts; Extended Packet
// count=N: skip next N; Skip Packet
//
// Repeat Packet:
// 1 type and count, always 0x00 for this packet type
// 1 Repeat count
// 1 Repeated pixel
//
// Quote Packet:
// 1 type and count
// - bit 7: type flag; always 0 for this packet type
// - bits 0-6: Quoted pixel count
// ? Quoted pixels; count specified by previous byte
//
// Skip Packet:
// 1 type and count
// - bit 7: type flag; always 1 for this packet type
// - bits 0-6: Skipped pixel count; the pixels are copied
// from the same location in the previous frame
//
// Extended Packet (typed packets follow and include the data described here):
// 1 type and count, always 0x80 for this packet type
// 2 extended type and count
// - bit 15: type flag1 (FD_EXT_FLAG1)
// when 0: Extended Skip Packet
// - bits 0-14: Skipped pixel count
// when 1:
// - bit 14: type flag2 (FD_EXT_FLAG2)
// when 0: Extended Quote Packet
// when 1: Extended Repeat Packet
// - bits 0-13: Repeat/Quote pixel count
//
// Extended Skip Packet:
// 1 type and count, always 0x80 for this packet type
// 2 extended type and count
// - bit 15: type flag1 (FD_EXT_FLAG1), always 0
// - bits 0-14: Skipped pixel count; the pixels are copied
// from the same location in the previous frame
//
// Extended Quote Packet:
// 1 type and count, always 0x80 for this packet type
// 2 extended type and count
// - bit 15: type flag1 (FD_EXT_FLAG1), always 1
// - bit 14: type flag2 (FD_EXT_FLAG2), always 0
// - bits 0-13: Quoted pixel count
// ? Quoted pixels; count specified by previous word
//
// Extended Repeat Packet:
// 1 type and count, always 0x80 for this packet type
// 2 extended type and count
// - bit 15: type flag1 (FD_EXT_FLAG1), always 1
// - bit 14: type flag2 (FD_EXT_FLAG2), always 1
// - bits 0-13: Repeat count
// 1 Repeated pixel
//
#define FD_EXT_FLAG 0x0080
#define FD_COUNT_MASK 0x007f
#define FD_EXT_FLAG1 0x8000
#define FD_EXT_FLAG2 0x4000
#define FD_EXT_SCOUNT_MASK 0x7fff
#define FD_EXT_RCOUNT_MASK 0x3fff
#define FD_EXT_QCOUNT_MASK FD_EXT_RCOUNT_MASK
#if defined(_MSC_VER)
# pragma pack(pop)
#endif
#undef PACKED
File diff suppressed because it is too large Load Diff
+110
View File
@@ -0,0 +1,110 @@
# Microsoft Developer Studio Project File - Name="lpf2ani" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=lpf2ani - 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 "lpf2ani.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 "lpf2ani.mak" CFG="lpf2ani - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "lpf2ani - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "lpf2ani - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=xicl6.exe
RSC=rc.exe
!IF "$(CFG)" == "lpf2ani - 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 "..\..\src\getopt" /I "." /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "PNG_USE_DLL" /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=xilink6.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 advapi32.lib shell32.lib libpng10.lib libz.lib /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "lpf2ani - 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 Ignore_Export_Lib 0
# 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 /MD /W3 /Gm /GX /ZI /Od /I "..\..\src\getopt" /I "." /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "PNG_USE_DLL" /YX /FD /GZ /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=xilink6.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 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib advapi32.lib shell32.lib libpng10.lib libz.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "lpf2ani - Win32 Release"
# Name "lpf2ani - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\config.h
# End Source File
# Begin Source File
SOURCE=..\..\src\getopt\getopt.c
# End Source File
# Begin Source File
SOURCE=..\..\src\getopt\getopt.h
# End Source File
# Begin Source File
SOURCE=.\lpf.h
# End Source File
# Begin Source File
SOURCE=.\lpf2ani.c
# End Source File
# End Group
# End Target
# End Project
+29
View File
@@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "lpf2ani"=.\lpf2ani.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################