import: Mr Sprite hacked up for the sprites in this project
This commit is contained in:
parent
8ef6e58210
commit
54eae24600
|
@ -1,3 +1,13 @@
|
|||
obj/
|
||||
xrick.sys16
|
||||
bmp/
|
||||
*.vpj
|
||||
*.vpw
|
||||
*.vpwhist
|
||||
*.vtg
|
||||
bin/mrsprite/.vs/
|
||||
bin/mrsprite/Debug/
|
||||
bin/mrsprite/dep/
|
||||
bin/mrsprite/lst/
|
||||
*.lst
|
||||
*.d
|
||||
|
|
|
@ -0,0 +1,159 @@
|
|||
#--------------------------------------------------------
|
||||
# $File: Makefile,v $
|
||||
#
|
||||
# $Date: 8/12/2018 $
|
||||
# $Author: jandersen $
|
||||
# $Revision: #1 $
|
||||
#--------------------------------------------------------
|
||||
#
|
||||
# MrSprite GCC-Gnu Makefile
|
||||
#
|
||||
# Latest update - Just link with system libpng
|
||||
# You should keep this up2date anyways
|
||||
# On Ubuntu, something like this to install
|
||||
# sudo apt-get install libpng-dev
|
||||
#
|
||||
SHELL = /bin/sh
|
||||
MKDIR = mkdir
|
||||
|
||||
TARGET = mrsprite
|
||||
|
||||
PROJROOT = .
|
||||
|
||||
#SYSTEM = /usr
|
||||
#SYSLIBDIR = $(SYSTEM)/lib
|
||||
#SYSINCDIR = $(SYSTEM)/include
|
||||
|
||||
INCCMD = -I$(SYSINCDIR)
|
||||
INCCMD += -I$(PROJROOT)/source
|
||||
INCCMD += -I$(PROJROOT)/include
|
||||
|
||||
OBJDIR = $(PROJROOT)/obj
|
||||
DEPDIR = $(PROJROOT)/dep
|
||||
LSTDIR = $(PROJROOT)/lst
|
||||
|
||||
#
|
||||
# Special GnuMake Search Path Directive
|
||||
#
|
||||
VPATH = $(PROJROOT)/source
|
||||
|
||||
#
|
||||
# Dedicated Search Paths for Specific Types
|
||||
#
|
||||
# Can be used to speed up compile by using this feature
|
||||
# for each filetype (reducing the amount of searching)
|
||||
#
|
||||
vpath %.o $(OBJDIR)
|
||||
vpath %.d $(DEPDIR)
|
||||
|
||||
LIBCMD +=-lm -lpng
|
||||
|
||||
OBJS := Main.o
|
||||
OBJS += Dc_Code.o
|
||||
OBJS += Dc_Gif.o
|
||||
OBJS += Dc_Graphic.o
|
||||
OBJS += Dc_Memory.o
|
||||
OBJS += Dc_Shared.o
|
||||
|
||||
# change list of .o's into a list of .d's
|
||||
|
||||
DEPS := $(OBJS:%.o=%.d)
|
||||
|
||||
AS = gcc
|
||||
CC = gcc
|
||||
LD = gcc
|
||||
RM = /bin/rm -rfv
|
||||
|
||||
CFLAGS = -O2 -Wall -Werror -Wa,-al -fno-common
|
||||
CXXFLAGS = -O2 -Wall -Werror -Wa,-al -fno-common
|
||||
ASFLAGS = -c -xassembler-with-cpp -Wa,-al
|
||||
LDFLAGS = -Wl,-Map,$(TARGET).map $(LIBCMD)
|
||||
|
||||
# Clear Default Suffixes
|
||||
.SUFFIXES:
|
||||
# Set my Own Suffixes
|
||||
.SUFFIXES: .c .s .cc .d .o
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(DEPS) $(OBJS) $(LIBS)
|
||||
$(LD) -o $@ $(addprefix $(OBJDIR)/,$(OBJS)) $(LIBS) $(LDFLAGS)
|
||||
|
||||
# Object Rules
|
||||
|
||||
.s.o:
|
||||
$(AS) $(ASFLAGS) $(TMPFLAGS) $(INCCMD) -o $(OBJDIR)/$@ $< > $(LSTDIR)/$*.lst
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) $(TMPFLAGS) $(INCCMD) -c $< -o $(OBJDIR)/$*.o > $(LSTDIR)/$*.lst
|
||||
|
||||
.cc.o:
|
||||
$(CC) $(CXXFLAGS) $(TMPFLAGS) $(INCCMD) -c $< -o $(OBJDIR)/$*.o > $(LSTDIR)/$*.lst
|
||||
|
||||
# Dependencie Rules
|
||||
#
|
||||
# for now just touch, to create the file if its not defined
|
||||
#
|
||||
.s.d:
|
||||
touch $(DEPDIR)/$*.d
|
||||
|
||||
.c.d:
|
||||
set -e; $(CC) -M $(CFLAGS) $(INCCMD) $< \
|
||||
| sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $(DEPDIR)/$@; \
|
||||
[ -s $(DEPDIR)/$@ ] || rm -f $(DEPDIR)/$@
|
||||
|
||||
.cc.d:
|
||||
set -e; $(CC) -M $(CXXFLAGS) $(INCCMD) $< \
|
||||
| sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $(DEPDIR)/$@; \
|
||||
[ -s $(DEPDIR)/$@ ] || rm -f $(DEPDIR)/$@
|
||||
|
||||
.PHONY: install
|
||||
install: $(TARGET)
|
||||
cp $(TARGET).exe $(PROJROOT)/../bin
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(RM) $(OBJDIR) *.o $(DEPDIR) *.map $(LSTDIR) $(TARGET) $(TARGET).exe
|
||||
|
||||
|
||||
########################################
|
||||
#
|
||||
# HELPER TARGET RULES
|
||||
#
|
||||
########################################
|
||||
|
||||
#
|
||||
# Target that forces all of the objects to be rebuilt if the makefile changes
|
||||
#
|
||||
|
||||
$(OBJS) : Makefile
|
||||
$(DEPS) : Makefile
|
||||
#
|
||||
# Targets that create the output object directory if it doesn't already exist
|
||||
#
|
||||
|
||||
Makefile : $(OBJDIR) $(DEPDIR) $(LSTDIR)
|
||||
|
||||
$(OBJDIR) :
|
||||
$(MKDIR) $(OBJDIR)
|
||||
|
||||
#
|
||||
# Targets that create the output dependency directory if it doesn't already exist
|
||||
#
|
||||
|
||||
$(DEPDIR) :
|
||||
$(MKDIR) $(DEPDIR)
|
||||
|
||||
#
|
||||
# Targets that create the output list directory if it doesn't already exist
|
||||
#
|
||||
|
||||
$(LSTDIR) :
|
||||
$(MKDIR) $(LSTDIR)
|
||||
|
||||
#
|
||||
# Generated Dependencie Files
|
||||
#
|
||||
-include $(wildcard $(DEPDIR)/*.d)
|
||||
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27428.2043
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrsprite", "mrsprite.vcxproj", "{D5FCACC0-771C-4F8D-BD54-4E4725A6FF1A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D5FCACC0-771C-4F8D-BD54-4E4725A6FF1A}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{D5FCACC0-771C-4F8D-BD54-4E4725A6FF1A}.Debug|x64.Build.0 = Debug|x64
|
||||
{D5FCACC0-771C-4F8D-BD54-4E4725A6FF1A}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{D5FCACC0-771C-4F8D-BD54-4E4725A6FF1A}.Debug|x86.Build.0 = Debug|Win32
|
||||
{D5FCACC0-771C-4F8D-BD54-4E4725A6FF1A}.Release|x64.ActiveCfg = Release|x64
|
||||
{D5FCACC0-771C-4F8D-BD54-4E4725A6FF1A}.Release|x64.Build.0 = Release|x64
|
||||
{D5FCACC0-771C-4F8D-BD54-4E4725A6FF1A}.Release|x86.ActiveCfg = Release|Win32
|
||||
{D5FCACC0-771C-4F8D-BD54-4E4725A6FF1A}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {212A2123-E9D6-4288-A661-7041DA6D6E38}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,168 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="source\Dc_Code.c" />
|
||||
<ClCompile Include="source\Dc_Gif.c" />
|
||||
<ClCompile Include="source\Dc_Graphic.c" />
|
||||
<ClCompile Include="source\Dc_Memory.c" />
|
||||
<ClCompile Include="source\Dc_Shared.c" />
|
||||
<ClCompile Include="source\Main.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="source\Dc_Code.h" />
|
||||
<ClInclude Include="source\Dc_Gif.h" />
|
||||
<ClInclude Include="source\Dc_Graphic.h" />
|
||||
<ClInclude Include="source\Dc_Memory.h" />
|
||||
<ClInclude Include="source\Dc_Shared.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{D5FCACC0-771C-4F8D-BD54-4E4725A6FF1A}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>mrsprite</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<DisableSpecificWarnings>C4267;C4101;C4267</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -0,0 +1,54 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="source\Dc_Code.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\Dc_Gif.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\Dc_Graphic.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\Dc_Memory.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\Dc_Shared.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\Main.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="source\Dc_Code.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\Dc_Gif.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\Dc_Graphic.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\Dc_Memory.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\Dc_Shared.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,57 @@
|
|||
/********************************************************************
|
||||
* *
|
||||
* Dc_Code.h : Header de gestion des lignes de Code. *
|
||||
* *
|
||||
********************************************************************
|
||||
* Auteur : Olivier ZARDINI * Brutal Deluxe * Date : Jan 2013 *
|
||||
********************************************************************/
|
||||
|
||||
#define BANK_TOTAL_SIZE 65536
|
||||
#define BANK_HEADER_SIZE 9
|
||||
|
||||
/*
|
||||
4B AB 0A AA 7C 07 00 00 00
|
||||
PHK
|
||||
PLB
|
||||
ASL
|
||||
TAX
|
||||
JMP TableSprite,X
|
||||
StackAddress HEX 0000
|
||||
TableSprite DA
|
||||
*/
|
||||
|
||||
struct code_line
|
||||
{
|
||||
char label[32];
|
||||
char opcode[16];
|
||||
char operand[16];
|
||||
char comment[256];
|
||||
|
||||
int nb_byte;
|
||||
int nb_cycle;
|
||||
|
||||
struct code_line *next;
|
||||
};
|
||||
|
||||
struct code_file
|
||||
{
|
||||
int index; /* Numéro du sprite */
|
||||
|
||||
int size; /* Taille du code objet */
|
||||
unsigned char object[65536];
|
||||
|
||||
int bank_number; /* Numero du bank */
|
||||
int index_bank; /* Numero du Spirte dans le bank */
|
||||
|
||||
struct code_file *next;
|
||||
};
|
||||
|
||||
// prototype
|
||||
struct picture_256;
|
||||
|
||||
void BuildCodeLine(struct picture_256 *,struct picture_256 *,int);
|
||||
int LoadSpriteCode(char *);
|
||||
int BuildCodeBank(char *,char *,int *);
|
||||
int CreateMainCode(char *,char *,int);
|
||||
|
||||
/********************************************************************/
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,18 @@
|
|||
/*****************************************************************
|
||||
* *
|
||||
* Dc_Gif.h : Header de gestion des fichiers GIF. *
|
||||
* *
|
||||
*****************************************************************
|
||||
* Auteur : Olivier ZARDINI * CooperTeam * Date : Jui 2005 *
|
||||
*****************************************************************/
|
||||
|
||||
#define GR_ERR_NOERROR 0
|
||||
#define GR_ERR_MEMORY (-100)
|
||||
#define GR_ERR_BADFORMAT (-160)
|
||||
#define GR_ERR_OPENFILE (-210)
|
||||
|
||||
struct picture_true *GIFReadFileToRGB(char *);
|
||||
struct picture_256 *GIFReadFileTo256Color(char *);
|
||||
int GIFWriteFileFrom256Color(char *,struct picture_256 *);
|
||||
|
||||
/****************************************************************/
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,56 @@
|
|||
/********************************************************************
|
||||
* *
|
||||
* Dc_Graphic.h : Header de gestion des fichiers Graphiques. *
|
||||
* *
|
||||
********************************************************************
|
||||
* Auteur : Olivier ZARDINI * Brutal Deluxe * Date : Nov 2012 *
|
||||
********************************************************************/
|
||||
|
||||
#define TOO_MANY_COLOR 1
|
||||
#define ERR_GRAPHIC_FOPEN 2
|
||||
#define ERR_ALLOC 3
|
||||
#define ERR_GRAPHIC_BADFORMAT 4
|
||||
#define ERR_GRAPHIC_WRITEFILE 5
|
||||
|
||||
struct picture_256
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
|
||||
int nb_color;
|
||||
int palette_red[256];
|
||||
int palette_green[256];
|
||||
int palette_blue[256];
|
||||
|
||||
unsigned char *data;
|
||||
|
||||
/* Stat */
|
||||
int *tab_nb_color; /* Nombre de couleur sur la ligne */
|
||||
int *tab_color_line; /* Nombre de points utilisant chaque couleur */
|
||||
};
|
||||
|
||||
struct picture_true
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
|
||||
unsigned char *data;
|
||||
};
|
||||
|
||||
DWORD DecodeRGBColor(char *);
|
||||
int ExtractAllSprite(char *,DWORD,DWORD);
|
||||
int CreateMirrorPicture(char *,DWORD);
|
||||
int CreateFlipPicture(char *,DWORD);
|
||||
int CreateOddPicture(char *,DWORD);
|
||||
int RemoveDuplicatedPictures(int,char **);
|
||||
int CreateWallPaper(int,char **,DWORD,DWORD);
|
||||
int CreateSpriteCode(char *,DWORD,int,DWORD *,int);
|
||||
int Compute8BitColors(int,int,int,unsigned char *,int *);
|
||||
struct picture_256 *ConvertTrueColorTo256(struct picture_true *);
|
||||
void PlotTrueColor(int,int,unsigned char,unsigned char,unsigned char,struct picture_true *);
|
||||
int PlotNumber(int,int,int,unsigned char,unsigned char,unsigned char,struct picture_true *);
|
||||
struct picture_256 *CreateEmptyPicture(int,int,int,int *,int *,int *,unsigned char);
|
||||
void mem_free_picture_256(struct picture_256 *);
|
||||
void mem_free_picture_true(struct picture_true *);
|
||||
|
||||
/********************************************************************/
|
|
@ -0,0 +1,510 @@
|
|||
/*****************************************************************
|
||||
* *
|
||||
* Dc_Memory.c : Module de gestion des ressources memoires. *
|
||||
* *
|
||||
*****************************************************************
|
||||
* Auteur : Olivier ZARDINI * CooperTeam * Date : Jan 2013 *
|
||||
*****************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "Dc_Code.h"
|
||||
#include "Dc_Shared.h"
|
||||
#include "Dc_Memory.h"
|
||||
|
||||
int compare_pattern(const void *,const void *);
|
||||
|
||||
/******************************************************/
|
||||
/* my_Memory() : Fonction de gestion de la mémoire. */
|
||||
/******************************************************/
|
||||
void my_Memory(int code, void *data, void *value)
|
||||
{
|
||||
int i, index;
|
||||
WORD pattern_data;
|
||||
static int nb_pattern; /* Pattern */
|
||||
static struct pattern *first_pattern;
|
||||
static struct pattern *last_pattern;
|
||||
struct pattern *current_pattern;
|
||||
struct pattern *next_pattern;
|
||||
struct pattern **tab_pattern;
|
||||
static int nb_redpattern; /* Red Pattern */
|
||||
static struct pattern *first_redpattern;
|
||||
static struct pattern *last_redpattern;
|
||||
struct pattern *current_redpattern;
|
||||
struct pattern *next_redpattern;
|
||||
struct pattern **tab_redpattern;
|
||||
static int nb_codeline; /* Ligne de Code */
|
||||
static struct code_line *first_codeline;
|
||||
static struct code_line *last_codeline;
|
||||
struct code_line *current_codeline;
|
||||
struct code_line *next_codeline;
|
||||
static char buffer_comment[512]; /* Commentaire */
|
||||
static int nb_codefile; /* Fichier de Code */
|
||||
static struct code_file *first_codefile;
|
||||
static struct code_file *last_codefile;
|
||||
struct code_file *current_codefile;
|
||||
struct code_file *next_codefile;
|
||||
struct code_file **tab_codefile;
|
||||
|
||||
switch(code)
|
||||
{
|
||||
case MEMORY_INIT :
|
||||
nb_pattern = 0;
|
||||
first_pattern = NULL;
|
||||
last_pattern = NULL;
|
||||
nb_redpattern = 0;
|
||||
first_redpattern = NULL;
|
||||
last_redpattern = NULL;
|
||||
nb_codeline = 0;
|
||||
first_codeline = NULL;
|
||||
last_codeline = NULL;
|
||||
strcpy(buffer_comment,"");
|
||||
nb_codefile = 0;
|
||||
first_codefile = NULL;
|
||||
last_codefile = NULL;
|
||||
break;
|
||||
|
||||
case MEMORY_FREE :
|
||||
my_Memory(MEMORY_FREE_PATTERN,NULL,NULL);
|
||||
my_Memory(MEMORY_FREE_REDPATTERN,NULL,NULL);
|
||||
my_Memory(MEMORY_FREE_CODELINE,NULL,NULL);
|
||||
my_Memory(MEMORY_FREE_CODEFILE,NULL,NULL);
|
||||
break;
|
||||
|
||||
/*************************/
|
||||
/* Gestion des Pattern */
|
||||
/*************************/
|
||||
case MEMORY_ADD_PATTERN :
|
||||
pattern_data = *((WORD *) data);
|
||||
|
||||
/* A t'on déjà cette pattern */
|
||||
for(current_pattern=first_pattern; current_pattern; current_pattern=current_pattern->next)
|
||||
if(current_pattern->pattern_data == pattern_data)
|
||||
{
|
||||
current_pattern->nb_found++;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Création d'une nouvelle */
|
||||
current_pattern = (struct pattern *) calloc(1,sizeof(struct pattern));
|
||||
if(current_pattern == NULL)
|
||||
return;
|
||||
current_pattern->pattern_data = pattern_data;
|
||||
current_pattern->nb_found = 1;
|
||||
|
||||
/* Attachement à la liste */
|
||||
if(first_pattern == NULL)
|
||||
first_pattern = current_pattern;
|
||||
else
|
||||
last_pattern->next = current_pattern;
|
||||
last_pattern = current_pattern;
|
||||
nb_pattern++;
|
||||
break;
|
||||
|
||||
case MEMORY_GET_PATTERN_NB :
|
||||
*((int *) data) = nb_pattern;
|
||||
break;
|
||||
|
||||
case MEMORY_GET_PATTERN :
|
||||
index = *((int *)data);
|
||||
*((struct pattern **) value) = NULL;
|
||||
if(index <= 0 || index > nb_pattern)
|
||||
break;
|
||||
|
||||
for(i=1,current_pattern=first_pattern; i<=nb_pattern; i++,current_pattern=current_pattern->next)
|
||||
if(i == index)
|
||||
{
|
||||
*((struct pattern **) value) = current_pattern;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case MEMORY_GET_PATTERN_SCORE :
|
||||
pattern_data = *((WORD *) data);
|
||||
for(i=0,current_pattern=first_pattern; current_pattern; current_pattern=current_pattern->next,i++)
|
||||
{
|
||||
if(i > 2) /* On ne prend en compte que les 3 premiers Pattern stockées dans les registres 16 bits X, Y et D */
|
||||
break;
|
||||
else if(current_pattern->pattern_data == pattern_data)
|
||||
{
|
||||
*((int *) value) = current_pattern->nb_found;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Pas trouvé */
|
||||
*((int *) value) = 0;
|
||||
break;
|
||||
|
||||
case MEMORY_SORT_PATTERN :
|
||||
if(nb_pattern == 0 || nb_pattern == 1)
|
||||
break;
|
||||
|
||||
/* Allocation */
|
||||
tab_pattern = (struct pattern **) calloc(nb_pattern,sizeof(struct pattern *));
|
||||
if(tab_pattern == NULL)
|
||||
return;
|
||||
|
||||
/* Remplissage */
|
||||
for(i=0, current_pattern = first_pattern; current_pattern; current_pattern = current_pattern->next,i++)
|
||||
tab_pattern[i] = current_pattern;
|
||||
|
||||
/* Tri */
|
||||
qsort(tab_pattern,nb_pattern,sizeof(struct pattern *),compare_pattern);
|
||||
|
||||
/* Recablage */
|
||||
first_pattern = tab_pattern[0];
|
||||
last_pattern = tab_pattern[nb_pattern-1];
|
||||
last_pattern->next = NULL;
|
||||
for(i=0; i<nb_pattern-1; i++)
|
||||
tab_pattern[i]->next = tab_pattern[i+1];
|
||||
|
||||
/* Libération */
|
||||
free(tab_pattern);
|
||||
break;
|
||||
|
||||
case MEMORY_FREE_PATTERN :
|
||||
for(current_pattern=first_pattern; current_pattern; )
|
||||
{
|
||||
next_pattern = current_pattern->next;
|
||||
free(current_pattern);
|
||||
current_pattern = next_pattern;
|
||||
}
|
||||
nb_pattern = 0;
|
||||
first_pattern = NULL;
|
||||
last_pattern = NULL;
|
||||
break;
|
||||
|
||||
|
||||
/*****************************/
|
||||
/* Gestion des Red Pattern */
|
||||
/*****************************/
|
||||
case MEMORY_ADD_REDPATTERN :
|
||||
pattern_data = *((WORD *) data);
|
||||
|
||||
/* A t'on déjà cette pattern */
|
||||
for(current_redpattern=first_redpattern; current_redpattern; current_redpattern=current_redpattern->next)
|
||||
if(current_redpattern->pattern_data == pattern_data)
|
||||
{
|
||||
current_redpattern->nb_found++;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Création d'une nouvelle */
|
||||
current_redpattern = (struct pattern *) calloc(1,sizeof(struct pattern));
|
||||
if(current_redpattern == NULL)
|
||||
return;
|
||||
current_redpattern->pattern_data = pattern_data;
|
||||
current_redpattern->nb_found = 1;
|
||||
|
||||
/* Attachement à la liste */
|
||||
if(first_redpattern == NULL)
|
||||
first_redpattern = current_redpattern;
|
||||
else
|
||||
last_redpattern->next = current_redpattern;
|
||||
last_redpattern = current_redpattern;
|
||||
nb_redpattern++;
|
||||
break;
|
||||
|
||||
case MEMORY_GET_REDPATTERN :
|
||||
index = *((int *) data);
|
||||
*((struct pattern **) value) = NULL;
|
||||
if(index <= 0 || index > nb_redpattern)
|
||||
break;
|
||||
|
||||
for(i=1,current_redpattern=first_redpattern; i<=nb_redpattern; i++,current_redpattern=current_redpattern->next)
|
||||
if(i == index)
|
||||
{
|
||||
*((struct pattern **) value) = current_redpattern;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case MEMORY_SORT_REDPATTERN :
|
||||
if(nb_redpattern == 0 || nb_redpattern == 1)
|
||||
break;
|
||||
|
||||
/* Allocation */
|
||||
tab_redpattern = (struct pattern **) calloc(nb_redpattern,sizeof(struct pattern *));
|
||||
if(tab_redpattern == NULL)
|
||||
return;
|
||||
|
||||
/* Remplissage */
|
||||
for(i=0, current_redpattern = first_redpattern; current_redpattern; current_redpattern = current_redpattern->next,i++)
|
||||
tab_redpattern[i] = current_redpattern;
|
||||
|
||||
/* Tri */
|
||||
qsort(tab_redpattern,nb_redpattern,sizeof(struct pattern *),compare_pattern);
|
||||
|
||||
/* Recablage */
|
||||
first_redpattern = tab_redpattern[0];
|
||||
last_redpattern = tab_redpattern[nb_redpattern-1];
|
||||
last_redpattern->next = NULL;
|
||||
for(i=0; i<nb_redpattern-1; i++)
|
||||
tab_redpattern[i]->next = tab_redpattern[i+1];
|
||||
|
||||
/* Libération */
|
||||
free(tab_redpattern);
|
||||
break;
|
||||
|
||||
case MEMORY_FREE_REDPATTERN :
|
||||
for(current_redpattern=first_redpattern; current_redpattern; )
|
||||
{
|
||||
next_redpattern = current_redpattern->next;
|
||||
free(current_redpattern);
|
||||
current_redpattern = next_redpattern;
|
||||
}
|
||||
nb_redpattern = 0;
|
||||
first_redpattern = NULL;
|
||||
last_redpattern = NULL;
|
||||
break;
|
||||
|
||||
|
||||
/********************************/
|
||||
/* Gestion des Lignes de Code */
|
||||
/********************************/
|
||||
case MEMORY_ADD_CODELINE :
|
||||
current_codeline = (struct code_line *) data;
|
||||
|
||||
/* Attachement à la liste */
|
||||
if(first_codeline == NULL)
|
||||
first_codeline = current_codeline;
|
||||
else
|
||||
last_codeline->next = current_codeline;
|
||||
last_codeline = current_codeline;
|
||||
nb_codeline++;
|
||||
|
||||
/* Met le commentaire */
|
||||
if(strlen(buffer_comment) > 0 && strlen(current_codeline->comment) == 0)
|
||||
strcpy(current_codeline->comment,buffer_comment);
|
||||
|
||||
/* Vide le commentaire */
|
||||
strcpy(buffer_comment,"");
|
||||
break;
|
||||
|
||||
case MEMORY_GET_CODELINE_NB :
|
||||
*((int *) data) = nb_codeline;
|
||||
break;
|
||||
|
||||
case MEMORY_GET_CODELINE :
|
||||
index = *((int *) data);
|
||||
*((struct code_line **) value) = NULL;
|
||||
if(index <= 0 || index > nb_codeline)
|
||||
break;
|
||||
|
||||
for(i=1,current_codeline=first_codeline; i<=nb_codeline; i++,current_codeline=current_codeline->next)
|
||||
if(i == index)
|
||||
{
|
||||
*((struct code_line **) value) = current_codeline;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case MEMORY_DROP_CODELINE :
|
||||
/** Supprime la dernière ligne ajoutée **/
|
||||
if(last_codeline == NULL)
|
||||
return;
|
||||
if(nb_codeline == 1)
|
||||
{
|
||||
free(first_codeline);
|
||||
nb_codeline = 0;
|
||||
first_codeline = NULL;
|
||||
last_codeline = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Cas général */
|
||||
for(current_codeline=first_codeline; current_codeline; current_codeline=current_codeline->next)
|
||||
if(current_codeline->next == last_codeline)
|
||||
break;
|
||||
free(last_codeline);
|
||||
nb_codeline--;
|
||||
last_codeline = current_codeline;
|
||||
current_codeline->next = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case MEMORY_FREE_CODELINE :
|
||||
for(current_codeline=first_codeline; current_codeline; )
|
||||
{
|
||||
next_codeline = current_codeline->next;
|
||||
free(current_codeline);
|
||||
current_codeline = next_codeline;
|
||||
}
|
||||
nb_codeline = 0;
|
||||
first_codeline = NULL;
|
||||
last_codeline = NULL;
|
||||
break;
|
||||
|
||||
/*******************************************************/
|
||||
/* Commentaire à ajouter à la ligne de code suivante */
|
||||
/*******************************************************/
|
||||
case MEMORY_ADD_COMMENT :
|
||||
strcpy(buffer_comment,(char *)data);
|
||||
break;
|
||||
|
||||
/*******************************/
|
||||
/* Liste des fichiers Source */
|
||||
/*******************************/
|
||||
case MEMORY_ADD_CODEFILE :
|
||||
current_codefile = (struct code_file *) data;
|
||||
|
||||
/* Attachement à la liste */
|
||||
if(first_codefile == NULL)
|
||||
first_codefile = current_codefile;
|
||||
else
|
||||
last_codefile->next = current_codefile;
|
||||
last_codefile = current_codefile;
|
||||
nb_codefile++;
|
||||
break;
|
||||
|
||||
case MEMORY_GET_CODEFILE_NB :
|
||||
*((int *) data) = nb_codefile;
|
||||
break;
|
||||
|
||||
case MEMORY_GET_CODEFILE :
|
||||
index = *((int *) data);
|
||||
*((struct code_file **) value) = NULL;
|
||||
if(index <= 0 || index > nb_codefile)
|
||||
break;
|
||||
|
||||
for(i=1,current_codefile=first_codefile; i<=nb_codefile; i++,current_codefile=current_codefile->next)
|
||||
if(i == index)
|
||||
{
|
||||
*((struct code_file **) value) = current_codefile;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case MEMORY_SORT_CODEFILE :
|
||||
if(nb_codefile == 0 || nb_codefile == 1)
|
||||
break;
|
||||
|
||||
/* Allocation */
|
||||
tab_codefile = (struct code_file **) calloc(nb_codefile,sizeof(struct code_file *));
|
||||
if(tab_codefile == NULL)
|
||||
return;
|
||||
|
||||
/* Remplissage */
|
||||
for(i=0, current_codefile = first_codefile; current_codefile; current_codefile = current_codefile->next,i++)
|
||||
tab_codefile[i] = current_codefile;
|
||||
|
||||
/* Tri */
|
||||
qsort(tab_codefile,nb_codefile,sizeof(struct code_file *),(int (*)(const void *,const void *))data);
|
||||
|
||||
/* Recablage */
|
||||
first_codefile = tab_codefile[0];
|
||||
last_codefile = tab_codefile[nb_codefile-1];
|
||||
last_codefile->next = NULL;
|
||||
for(i=0; i<nb_codefile-1; i++)
|
||||
tab_codefile[i]->next = tab_codefile[i+1];
|
||||
|
||||
/* Libération */
|
||||
free(tab_codefile);
|
||||
break;
|
||||
|
||||
case MEMORY_FREE_CODEFILE :
|
||||
for(current_codefile=first_codefile; current_codefile; )
|
||||
{
|
||||
next_codefile = current_codefile->next;
|
||||
free(current_codefile);
|
||||
current_codefile = next_codefile;
|
||||
}
|
||||
nb_codefile = 0;
|
||||
first_codefile = NULL;
|
||||
last_codefile = NULL;
|
||||
break;
|
||||
|
||||
default :
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************/
|
||||
/* compare_pattern() : Fonction de comparaison des pattern. */
|
||||
/**************************************************************/
|
||||
int compare_pattern(const void *data_1, const void *data_2)
|
||||
{
|
||||
struct pattern *pattern_1;
|
||||
struct pattern *pattern_2;
|
||||
|
||||
/* Récupère les structures */
|
||||
pattern_1 = *((struct pattern **) data_1);
|
||||
pattern_2 = *((struct pattern **) data_2);
|
||||
|
||||
/* Comparaison du nb */
|
||||
if(pattern_1->nb_found < pattern_2->nb_found)
|
||||
return(1);
|
||||
else if(pattern_1->nb_found == pattern_2->nb_found)
|
||||
return(0);
|
||||
else
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* compare_codefile_size() : Fonction de comparaison des code_file. */
|
||||
/**********************************************************************/
|
||||
int compare_codefile_size(const void *data_1, const void *data_2)
|
||||
{
|
||||
struct code_file *codefile_1;
|
||||
struct code_file *codefile_2;
|
||||
|
||||
/* Récupère les structures */
|
||||
codefile_1 = *((struct code_file **) data_1);
|
||||
codefile_2 = *((struct code_file **) data_2);
|
||||
|
||||
/* Comparaison de la taille de l'objet */
|
||||
if(codefile_1->size < codefile_2->size)
|
||||
return(1);
|
||||
else if(codefile_1->size == codefile_2->size)
|
||||
return(0);
|
||||
else
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************/
|
||||
/* compare_codefile_num() : Fonction de comparaison des code_file. */
|
||||
/*********************************************************************/
|
||||
int compare_codefile_num(const void *data_1, const void *data_2)
|
||||
{
|
||||
struct code_file *codefile_1;
|
||||
struct code_file *codefile_2;
|
||||
|
||||
/* Récupère les structures */
|
||||
codefile_1 = *((struct code_file **) data_1);
|
||||
codefile_2 = *((struct code_file **) data_2);
|
||||
|
||||
/* Comparaison du numéro de l'objet */
|
||||
if(codefile_1->index > codefile_2->index)
|
||||
return(1);
|
||||
else if(codefile_1->index == codefile_2->index)
|
||||
return(0);
|
||||
else
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************/
|
||||
/* compare_filepath() : Fonction de comparaison des chemins. */
|
||||
/***************************************************************/
|
||||
int compare_filepath(const void *data_1, const void *data_2)
|
||||
{
|
||||
char *filepath_1;
|
||||
char *filepath_2;
|
||||
|
||||
/* Récupère les structures */
|
||||
filepath_1 = *((char **) data_1);
|
||||
filepath_2 = *((char **) data_2);
|
||||
|
||||
/* Comparaison des noms */
|
||||
return(my_stricmp(filepath_1,filepath_2));
|
||||
}
|
||||
|
||||
/*****************************************************************/
|
|
@ -0,0 +1,51 @@
|
|||
/*****************************************************************
|
||||
* *
|
||||
* Dc_Memory.h : Header de gestion des ressources memoires. *
|
||||
* *
|
||||
*****************************************************************
|
||||
* Auteur : Olivier ZARDINI * CooperTeam * Date : Jan 2013 *
|
||||
*****************************************************************/
|
||||
|
||||
#define MEMORY_INIT 1
|
||||
#define MEMORY_FREE 2
|
||||
|
||||
#define MEMORY_ADD_PATTERN 10
|
||||
#define MEMORY_GET_PATTERN_NB 11
|
||||
#define MEMORY_GET_PATTERN 12
|
||||
#define MEMORY_GET_PATTERN_SCORE 13
|
||||
#define MEMORY_SORT_PATTERN 14
|
||||
#define MEMORY_FREE_PATTERN 15
|
||||
|
||||
#define MEMORY_ADD_CODELINE 20
|
||||
#define MEMORY_GET_CODELINE_NB 21
|
||||
#define MEMORY_GET_CODELINE 22
|
||||
#define MEMORY_DROP_CODELINE 23
|
||||
#define MEMORY_FREE_CODELINE 25
|
||||
|
||||
#define MEMORY_ADD_REDPATTERN 30
|
||||
#define MEMORY_GET_REDPATTERN 32
|
||||
#define MEMORY_SORT_REDPATTERN 34
|
||||
#define MEMORY_FREE_REDPATTERN 35
|
||||
|
||||
#define MEMORY_ADD_COMMENT 40
|
||||
|
||||
#define MEMORY_ADD_CODEFILE 50
|
||||
#define MEMORY_GET_CODEFILE_NB 51
|
||||
#define MEMORY_GET_CODEFILE 52
|
||||
#define MEMORY_SORT_CODEFILE 53
|
||||
#define MEMORY_FREE_CODEFILE 54
|
||||
|
||||
struct pattern
|
||||
{
|
||||
WORD pattern_data;
|
||||
int nb_found;
|
||||
|
||||
struct pattern *next;
|
||||
};
|
||||
|
||||
void my_Memory(int,void *,void *);
|
||||
int compare_filepath(const void *,const void *);
|
||||
int compare_codefile_size(const void *,const void *);
|
||||
int compare_codefile_num(const void *,const void *);
|
||||
|
||||
/*****************************************************************/
|
|
@ -0,0 +1,705 @@
|
|||
/**********************************************************************
|
||||
* *
|
||||
* Dc_Shared.c : Module de la bibliothèque de fonctions génériques. *
|
||||
* *
|
||||
**********************************************************************
|
||||
* Auteur : Olivier ZARDINI * Brutal Deluxe * Date : Jan 2013 *
|
||||
**********************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/timeb.h>
|
||||
#include <direct.h>
|
||||
#ifndef WIN32
|
||||
//#include <dirent.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "Dc_Shared.h"
|
||||
|
||||
struct one_file
|
||||
{
|
||||
char *file_path;
|
||||
|
||||
struct one_file *next;
|
||||
};
|
||||
|
||||
struct one_file *LoadListFiles(char *);
|
||||
void mem_free_onefile_list(struct one_file *);
|
||||
int compare_file(const void *,const void *);
|
||||
char *my_strstr(char *,char *);
|
||||
int myq_stricmp(char *,char *);
|
||||
int myq_strnicmp(char *,char *,int);
|
||||
|
||||
/********************************************************************/
|
||||
/* BuildFileTab() : Construit un tableau de la liste de fichiers. */
|
||||
/********************************************************************/
|
||||
char **BuildFileTab(char *file_path, int *nb_file_rtn)
|
||||
{
|
||||
int i, nb_file;
|
||||
char **tab_file;
|
||||
struct one_file *first_file = NULL;
|
||||
struct one_file *current_file;
|
||||
|
||||
/** Cas particulier : un seul fichier **/
|
||||
if(strchr(file_path,'*') == NULL)
|
||||
{
|
||||
nb_file = 1;
|
||||
tab_file = (char **) calloc(1,sizeof(char *));
|
||||
if(tab_file == NULL)
|
||||
return(NULL);
|
||||
tab_file[0] = _strdup(file_path);
|
||||
if(tab_file[0] == NULL)
|
||||
{
|
||||
free(tab_file);
|
||||
return(NULL);
|
||||
}
|
||||
*nb_file_rtn = nb_file;
|
||||
return(tab_file);
|
||||
}
|
||||
|
||||
/*** Il faut récupérer la liste des fichiers ***/
|
||||
/* Charge tous les fichier en mémoire */
|
||||
first_file = LoadListFiles(file_path);
|
||||
if(first_file == NULL)
|
||||
return(NULL);
|
||||
|
||||
/* Compte le nombre de fichiers */
|
||||
for(nb_file=0,current_file = first_file; current_file; current_file = current_file->next)
|
||||
nb_file++;
|
||||
|
||||
/* Création du tableau d'accès rapide */
|
||||
tab_file = (char **) calloc(nb_file,sizeof(char *));
|
||||
if(tab_file == NULL)
|
||||
return(NULL);
|
||||
for(i=0,current_file = first_file; current_file; current_file = current_file->next,i++)
|
||||
{
|
||||
tab_file[i] = current_file->file_path;
|
||||
current_file->file_path = NULL;
|
||||
}
|
||||
|
||||
/* Libération de la liste */
|
||||
mem_free_onefile_list(first_file);
|
||||
|
||||
/* Tri les fichiers par ordre alphabétique */
|
||||
qsort(tab_file,nb_file,sizeof(char *),compare_file);
|
||||
|
||||
/* Renvoie le tableau */
|
||||
*nb_file_rtn = nb_file;
|
||||
return(tab_file);
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************/
|
||||
/* LoadListFiles() : Charge tous les fichiers binaires en mémoire. */
|
||||
/*********************************************************************/
|
||||
struct one_file *LoadListFiles(char *source_file_path)
|
||||
{
|
||||
#if defined(WIN32) || defined(WIN64)
|
||||
int i, rc;
|
||||
long hFile;
|
||||
int first_time = 1;
|
||||
struct _finddata_t c_file;
|
||||
char folder_path[1024];
|
||||
char buffer_file_path[1024];
|
||||
struct one_file *first_file = NULL;
|
||||
struct one_file *last_file = NULL;
|
||||
struct one_file *new_file;
|
||||
|
||||
/* Extrait le nom du répertoire */
|
||||
strcpy(folder_path,source_file_path);
|
||||
for(i=strlen(folder_path); i>=0; i--)
|
||||
if(folder_path[i] == FOLDER_SEPARATOR_CHAR) /* \ or / */
|
||||
{
|
||||
folder_path[i+1] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
/** On boucle sur tous les fichiers présents **/
|
||||
while(1)
|
||||
{
|
||||
if(first_time == 1)
|
||||
{
|
||||
hFile = _findfirst(source_file_path,&c_file);
|
||||
rc = (int) hFile;
|
||||
}
|
||||
else
|
||||
rc = _findnext(hFile,&c_file);
|
||||
|
||||
/* On analyse le résultat */
|
||||
if(rc == -1)
|
||||
break; /* no more files */
|
||||
first_time++;
|
||||
|
||||
/* On ne traite pas les dossiers **/
|
||||
if((c_file.attrib & _A_SUBDIR) == _A_SUBDIR)
|
||||
continue;
|
||||
|
||||
/** On traite cette entrée **/
|
||||
/* Chemin du fichier */
|
||||
sprintf(buffer_file_path,"%s%s",folder_path,c_file.name);
|
||||
|
||||
/** Conserve le chemin du fichier **/
|
||||
new_file = (struct one_file *) calloc(1,sizeof(struct one_file));
|
||||
if(new_file == NULL)
|
||||
{
|
||||
mem_free_onefile_list(first_file);
|
||||
_findclose(hFile);
|
||||
return(NULL);
|
||||
}
|
||||
new_file->file_path = _strdup(buffer_file_path);
|
||||
if(new_file->file_path == NULL)
|
||||
{
|
||||
free(new_file);
|
||||
mem_free_onefile_list(first_file);
|
||||
_findclose(hFile);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* Rattache à la liste chainée */
|
||||
if(first_file == NULL)
|
||||
first_file = new_file;
|
||||
else
|
||||
last_file->next = new_file;
|
||||
last_file = new_file;
|
||||
}
|
||||
|
||||
/* On ferme */
|
||||
_findclose(hFile);
|
||||
|
||||
return(first_file);
|
||||
#else
|
||||
DIR *dir;
|
||||
struct dirent *d;
|
||||
struct stat st;
|
||||
char folder_path[1024];
|
||||
char buffer_file_path[1024];
|
||||
struct one_file *first_file = NULL;
|
||||
struct one_file *last_file = NULL;
|
||||
struct one_file *new_file;
|
||||
|
||||
/* Extrait le nom du répertoire */
|
||||
strcpy(folder_path,source_file_path);
|
||||
for(int i=strlen(folder_path); i>=0; i--)
|
||||
if(folder_path[i] == FOLDER_SEPARATOR_CHAR) /* \ or / */
|
||||
{
|
||||
folder_path[i+1] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
/* Ouverture du répertoire */
|
||||
dir = opendir(folder_path);
|
||||
if(dir == NULL)
|
||||
return(NULL);
|
||||
|
||||
/* Passe toutes les entrées en revue */
|
||||
while((d = readdir(dir)))
|
||||
{
|
||||
/* On ignore . et .. */
|
||||
if(!strcmp(d->d_name,".") || !strcmp(d->d_name,".."))
|
||||
continue;
|
||||
|
||||
/* Nom complet */
|
||||
sprintf(buffer_file_path,"%s%c%s",folder_path,FOLDER_SEPARATOR_CHAR,d->d_name);
|
||||
|
||||
/* On ignore les dossier */
|
||||
stat(buffer_file_path,&st);
|
||||
if(S_ISDIR(st.st_mode))
|
||||
continue;
|
||||
|
||||
/* Le fichier fait t'il partie de la sélection */
|
||||
if(MatchHierarchy(buffer_file_path,source_file_path) == 0)
|
||||
continue;
|
||||
|
||||
/** Conserve le chemin du fichier **/
|
||||
new_file = (struct one_file *) calloc(1,sizeof(struct one_file));
|
||||
if(new_file == NULL)
|
||||
{
|
||||
mem_free_onefile_list(first_file);
|
||||
closedir(dir);
|
||||
return(NULL);
|
||||
}
|
||||
new_file->file_path = strdup(buffer_file_path);
|
||||
if(new_file->file_path == NULL)
|
||||
{
|
||||
free(new_file);
|
||||
mem_free_onefile_list(first_file);
|
||||
closedir(dir);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* Rattache à la liste chainée */
|
||||
if(first_file == NULL)
|
||||
first_file = new_file;
|
||||
else
|
||||
last_file->next = new_file;
|
||||
last_file = new_file;
|
||||
}
|
||||
|
||||
/* Fermeture du répertoire */
|
||||
closedir(dir);
|
||||
|
||||
/* Renvoie la liste de fichier */
|
||||
return(first_file);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/******************************************************/
|
||||
/* ExchangeByte() : Echange les 2 octets d'un WORD. */
|
||||
/******************************************************/
|
||||
WORD ExchangeByte(WORD pattern)
|
||||
{
|
||||
WORD new_pattern;
|
||||
|
||||
new_pattern = (pattern >> 8) | (pattern << 8);
|
||||
|
||||
return(new_pattern);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* mem_free_onefile_list() : Libération d'une liste de structures one_file. */
|
||||
/******************************************************************************/
|
||||
void mem_free_onefile_list(struct one_file *first_file)
|
||||
{
|
||||
struct one_file *current_file;
|
||||
struct one_file *next_file;
|
||||
|
||||
for(current_file=first_file; current_file; )
|
||||
{
|
||||
next_file = current_file->next;
|
||||
if(current_file->file_path)
|
||||
free(current_file->file_path);
|
||||
free(current_file);
|
||||
current_file = next_file;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************/
|
||||
/* compare_file() : On tri par ordre alphabétique. */
|
||||
/*****************************************************/
|
||||
int compare_file(const void *arg1, const void *arg2)
|
||||
{
|
||||
char *file_path1 = *((char **)arg1);
|
||||
char *file_path2 = *((char **)arg2);
|
||||
|
||||
/* On compare les deux chemin */
|
||||
return(my_stricmp(file_path1,file_path2));
|
||||
}
|
||||
|
||||
|
||||
/******************************************************/
|
||||
/* mem_free_list() : Libération mémoire du tableau. */
|
||||
/******************************************************/
|
||||
void mem_free_list(int nb_values, char **values)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* On libère le tableau */
|
||||
if(values)
|
||||
{
|
||||
for(i=0; i<nb_values; i++)
|
||||
if(values[i])
|
||||
free(values[i]);
|
||||
free(values);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
/* BuildListFromFile() : Récupère la liste des valeurs d'un fichier. */
|
||||
/***********************************************************************/
|
||||
char **BuildListFromFile(char *file_path, int *nb_value)
|
||||
{
|
||||
FILE *fd;
|
||||
int nb_line, line_length;
|
||||
char **tab;
|
||||
char buffer_line[1024];
|
||||
|
||||
/* Ouverture du fichier */
|
||||
fd = fopen(file_path,"r");
|
||||
if(fd == NULL)
|
||||
return(NULL);
|
||||
|
||||
/* Compte le nombre de lignes */
|
||||
nb_line = 0;
|
||||
fseek(fd,0L,SEEK_SET);
|
||||
while(fgets(buffer_line,1024-1,fd))
|
||||
nb_line++;
|
||||
|
||||
/* Allocation du tableau */
|
||||
tab = (char **) calloc(nb_line,sizeof(char *));
|
||||
if(tab == NULL)
|
||||
{
|
||||
fclose(fd);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/** Lecture du fichier **/
|
||||
nb_line = 0;
|
||||
fseek(fd,0L,SEEK_SET);
|
||||
while(fgets(buffer_line,1024-1,fd))
|
||||
{
|
||||
/** Traitement préliminaire de nettoyage **/
|
||||
line_length = strlen(buffer_line);
|
||||
if(line_length < 2) /* Ligne vide */
|
||||
continue;
|
||||
if(buffer_line[line_length-1] == '\n')
|
||||
buffer_line[line_length-1] = '\0'; /* On vire le \n final */
|
||||
|
||||
/** Stocke la valeur **/
|
||||
tab[nb_line] = _strdup(buffer_line);
|
||||
if(tab[nb_line] == NULL)
|
||||
{
|
||||
mem_free_list(nb_line,tab);
|
||||
fclose(fd);
|
||||
return(NULL);
|
||||
}
|
||||
nb_line++;
|
||||
}
|
||||
|
||||
/* Fermeture du fichier */
|
||||
fclose(fd);
|
||||
|
||||
/* Renvoi le tableau */
|
||||
*nb_value = nb_line;
|
||||
return(tab);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************/
|
||||
/* GetOneByte() : Décode un octet de l'operand. */
|
||||
/**************************************************/
|
||||
unsigned char GetOneByte(char *operand)
|
||||
{
|
||||
unsigned int integer;
|
||||
char buffer[10];
|
||||
|
||||
/** On reconnait la forme $XX **/
|
||||
if(strlen(operand) == 3)
|
||||
if(operand[0] == '$')
|
||||
{
|
||||
sscanf(&operand[1],"%02X",&integer);
|
||||
return((unsigned char)integer);
|
||||
}
|
||||
|
||||
/** On reconnait la forme #$XX **/
|
||||
if(strlen(operand) == 4)
|
||||
if(!my_strnicmp(operand,"#$",2))
|
||||
{
|
||||
sscanf(&operand[2],"%02X",&integer);
|
||||
return((unsigned char)integer);
|
||||
}
|
||||
|
||||
/** On reconnait la forme $XX,S **/
|
||||
if(strlen(operand) == 5)
|
||||
if(operand[0] == '$' && !my_stricmp(&operand[3],",S"))
|
||||
{
|
||||
buffer[0] = operand[1];
|
||||
buffer[1] = operand[2];
|
||||
buffer[2] = '\0';
|
||||
sscanf(buffer,"%02X",&integer);
|
||||
return((unsigned char)integer);
|
||||
}
|
||||
|
||||
/* Inconnu */
|
||||
return(0x00);
|
||||
}
|
||||
|
||||
|
||||
/*************************************************/
|
||||
/* GetOneWord() : Décode un WORD de l'operand. */
|
||||
/*************************************************/
|
||||
WORD GetOneWord(char *operand)
|
||||
{
|
||||
unsigned int integer;
|
||||
|
||||
/** On reconnait la forme $XXXX **/
|
||||
if(strlen(operand) == 5)
|
||||
if(operand[0] == '$')
|
||||
{
|
||||
sscanf(&operand[1],"%04X",&integer);
|
||||
return((WORD)integer);
|
||||
}
|
||||
|
||||
/** On reconnait la forme #$XXXX **/
|
||||
if(strlen(operand) == 6)
|
||||
if(!my_strnicmp(operand,"#$",2))
|
||||
{
|
||||
sscanf(&operand[2],"%04X",&integer);
|
||||
return((WORD)integer);
|
||||
}
|
||||
|
||||
/* Inconnu */
|
||||
return(0x0000);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************/
|
||||
/* Get24Bit() : Décode 24 bit de l'operand. */
|
||||
/**********************************************/
|
||||
DWORD Get24Bit(char *operand)
|
||||
{
|
||||
unsigned int integer;
|
||||
|
||||
/** On reconnait la forme $XXXXXX **/
|
||||
if(strlen(operand) == 7)
|
||||
if(operand[0] == '$')
|
||||
{
|
||||
sscanf(&operand[1],"%06X",&integer);
|
||||
return((DWORD)integer);
|
||||
}
|
||||
|
||||
/* Inconnu */
|
||||
return(0x000000);
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* RenameAllFiles() : Renomme tous les fichiers de manière incrémentale. */
|
||||
/***************************************************************************/
|
||||
int RenameAllFiles(int nb_file, char **tab_file, char *file_name_prefix, char *file_name_extension)
|
||||
{
|
||||
int i, result;
|
||||
char folder_path[1024];
|
||||
char file_path[1024];
|
||||
|
||||
/* Chemin du dossier */
|
||||
strcpy(folder_path,tab_file[0]);
|
||||
for(i=strlen(folder_path); i>=0; i--)
|
||||
if(folder_path[i] == FOLDER_SEPARATOR_CHAR) /* \ or / */
|
||||
{
|
||||
folder_path[i+1] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
/** Traite tous les fichiers**/
|
||||
for(i=0; i<nb_file; i++)
|
||||
{
|
||||
/* Nouveau nom */
|
||||
sprintf(file_path,"%s%s_%03d.%s",folder_path,file_name_prefix,i,file_name_extension);
|
||||
|
||||
/* Renommage */
|
||||
result = rename(tab_file[i],file_path);
|
||||
if(result != 0)
|
||||
printf(" Error : Impossible to rename file '%s' as '%s'",tab_file[i],file_path);
|
||||
}
|
||||
|
||||
/* OK */
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* my_stricmp() : On compare les chaines de caractère sans la casse. */
|
||||
/************************************************************************/
|
||||
int my_stricmp(char *s1, char *s2)
|
||||
{
|
||||
#if defined(WIN32) || defined(WIN64)
|
||||
return(_stricmp(s1,s2));
|
||||
#else
|
||||
/* Cette fonction n'existe pas de façon native sous Unix */
|
||||
for( ; ( *s1 && *s2 ) && (((tolower)(*s1)) == ((tolower)(*s2))); s1++, s2++)
|
||||
;
|
||||
|
||||
return(((tolower)(*s1)) - ((tolower)(*s2)));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* my_strnicmp() : On compare les chaines de caractère sans la casse. */
|
||||
/*************************************************************************/
|
||||
int my_strnicmp(char *s1, char *s2, int length)
|
||||
{
|
||||
#if defined(WIN32) || defined(WIN64)
|
||||
return(_strnicmp(s1,s2,length));
|
||||
#else
|
||||
/* Cette fonction n'existe pas de façon native sous Unix */
|
||||
if(length == 0)
|
||||
return(0);
|
||||
|
||||
for( ; (*s1!=0) && (*s2!=0) && (length>0); s1++, s2++, length--)
|
||||
if(((tolower)(*s1)) != ((tolower)((*s2))))
|
||||
return(((tolower)(*s1)) - ((tolower)(*s2)));
|
||||
|
||||
if(length == 0)
|
||||
return(0);
|
||||
else
|
||||
return(1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* MatchHierarchy() : Indique si un nom appartient à une hiérarchie. */
|
||||
/**********************************************************************/
|
||||
int MatchHierarchy(char *name, char *hierarchie)
|
||||
{
|
||||
int i,j,k;
|
||||
int length;
|
||||
char *hier_ptr;
|
||||
char *name_ptr;
|
||||
int result;
|
||||
int count;
|
||||
size_t offset;
|
||||
char buffer[2048];
|
||||
|
||||
/*** On parcours les deux chaînes ***/
|
||||
for(i=0,j=0; i<(int)strlen(hierarchie); i++)
|
||||
{
|
||||
if(hierarchie[i] != '*')
|
||||
{
|
||||
if(toupper(hierarchie[i]) != toupper(name[j]) &&
|
||||
!(hierarchie[i] == '/' && name[j] == '\\') &&
|
||||
!(hierarchie[i] == '\\' && name[j] == '/'))
|
||||
return(0);
|
||||
j++;
|
||||
}
|
||||
else if(hierarchie[i] == '?')
|
||||
j++;
|
||||
else
|
||||
{
|
||||
/* Si '*' dernier caractère de la chaîne => OK */
|
||||
if(hierarchie[i+1] == '\0')
|
||||
return(1);
|
||||
|
||||
/** S'il ne reste pas d'autre '*' : On compare la fin **/
|
||||
hier_ptr = strchr(&hierarchie[i+1],'*');
|
||||
if(hier_ptr == NULL)
|
||||
{
|
||||
length = (int)strlen(&hierarchie[i+1]);
|
||||
if((int)strlen(&name[j]) < length)
|
||||
return(0);
|
||||
if(!myq_stricmp(&name[strlen(name)-length],&hierarchie[i+1]))
|
||||
return(1);
|
||||
else
|
||||
return(0);
|
||||
}
|
||||
|
||||
/** On compte le nb d'occurences de la partie entre les deux '*' dans name **/
|
||||
strncpy(buffer,&hierarchie[i+1],hier_ptr-&hierarchie[i+1]);
|
||||
buffer[hier_ptr-&hierarchie[i+1]] = '\0';
|
||||
length = (int)strlen(buffer);
|
||||
for(count = 0,offset = j;;count++)
|
||||
{
|
||||
name_ptr = my_strstr(&name[offset],buffer);
|
||||
if(name_ptr == NULL)
|
||||
break;
|
||||
offset = (name_ptr - name) + 1;
|
||||
}
|
||||
/* Si aucune occurence => pas de matching */
|
||||
if(count == 0)
|
||||
return(0);
|
||||
|
||||
/** On lance la récursivité sur toutes les occurences trouvées **/
|
||||
for(k=0,offset=j; k<count; k++)
|
||||
{
|
||||
name_ptr = my_strstr(&name[offset],buffer);
|
||||
result = MatchHierarchy(name_ptr+length,&hierarchie[i+1+length]);
|
||||
if(result)
|
||||
return(1);
|
||||
offset = (name_ptr - name) + 1;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* On est arrivé au bout : OK */
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* my_strstr() : Recherche l'occurence d'une chaîne dans une autre. */
|
||||
/**********************************************************************/
|
||||
char *my_strstr(char *name, char *hierarchie)
|
||||
{
|
||||
int i;
|
||||
int length_n = (int)strlen(name);
|
||||
int length_h = (int)strlen(hierarchie);
|
||||
|
||||
/* On élimine les cas extrêmes */
|
||||
if(length_n < length_h)
|
||||
return(NULL);
|
||||
|
||||
/** On parcours la chaîne 'name' afin de localiser la chaine 'hierarchie' **/
|
||||
for(i=0; i<length_n-length_h+1; i++)
|
||||
{
|
||||
/* La recherche tient compte des '?' */
|
||||
if(!myq_strnicmp(&name[i],hierarchie,length_h))
|
||||
return(&name[i]);
|
||||
}
|
||||
|
||||
/* On a rien trouvé */
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************/
|
||||
/* myq_stricmp() : Compare deux chaînes de caractères avec les '?'. */
|
||||
/********************************************************************/
|
||||
int myq_stricmp(char *string_n, char *string_h)
|
||||
{
|
||||
int i;
|
||||
int length_n = (int)strlen(string_n);
|
||||
int length_h = (int)strlen(string_h);
|
||||
|
||||
/* On élimine immédiatement les cas défavorables */
|
||||
if(length_n != length_h)
|
||||
return(1);
|
||||
|
||||
/** On compare tous les caractères avec gestion du '?' **/
|
||||
for(i=0; i<length_n; i++)
|
||||
{
|
||||
if(string_h[i] == '?')
|
||||
continue;
|
||||
else if((toupper(string_n[i]) != toupper(string_h[i])) &&
|
||||
!(string_n[i]=='\\' && string_h[i]=='/') &&
|
||||
!(string_n[i]=='/' && string_h[i]=='\\'))
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* On a deux chaînes identiques */
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************/
|
||||
/* myq_strnicmp() : Compare deux chaînes de caractères avec les '?'. */
|
||||
/*********************************************************************/
|
||||
int myq_strnicmp(char *string_n, char *string_h, int length)
|
||||
{
|
||||
int i;
|
||||
int length_n = (int)strlen(string_n);
|
||||
int length_h = (int)strlen(string_h);
|
||||
|
||||
/* On élimine immédiatement les cas défavorables */
|
||||
if(length_n < length || length_h < length)
|
||||
return(1);
|
||||
|
||||
/** On compare tous les caractères avec gestion du '?' **/
|
||||
for(i=0; i<length; i++)
|
||||
{
|
||||
if(string_h[i] == '?')
|
||||
continue;
|
||||
else if(toupper(string_n[i]) != toupper(string_h[i]))
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* On a deux chaînes identiques */
|
||||
return(0);
|
||||
}
|
||||
|
||||
/********************************************************************/
|
|
@ -0,0 +1,31 @@
|
|||
/**********************************************************************
|
||||
* *
|
||||
* Dc_Shared.h : Header de la bibliothèque de fonctions génériques. *
|
||||
* *
|
||||
**********************************************************************
|
||||
* Auteur : Olivier ZARDINI * Brutal Deluxe * Date : Jan 2013 *
|
||||
**********************************************************************/
|
||||
|
||||
typedef unsigned int DWORD; /* Unsigned 32 bit */
|
||||
typedef unsigned short WORD; /* Unsigned 16 bit */
|
||||
typedef unsigned char BYTE; /* Unsigned 8 bit */
|
||||
|
||||
#if defined(WIN32) || defined(WIN64)
|
||||
#define FOLDER_SEPARATOR_CHAR '\\'
|
||||
#else
|
||||
#define FOLDER_SEPARATOR_CHAR '/'
|
||||
#endif
|
||||
|
||||
char **BuildFileTab(char *,int *);
|
||||
WORD ExchangeByte(WORD);
|
||||
char **BuildListFromFile(char *,int *);
|
||||
void mem_free_list(int,char **);
|
||||
unsigned char GetOneByte(char *);
|
||||
WORD GetOneWord(char *);
|
||||
DWORD Get24Bit(char *);
|
||||
int RenameAllFiles(int,char **,char *,char *);
|
||||
int my_stricmp(char *,char *);
|
||||
int my_strnicmp(char *,char *,int);
|
||||
int MatchHierarchy(char *,char *);
|
||||
|
||||
/********************************************************************/
|
|
@ -0,0 +1,363 @@
|
|||
/*****************************************************************************/
|
||||
/* */
|
||||
/* MrSprite : Outil de génération de code pour Sprite sur Apple IIgs. */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* Auteur : Olivier ZARDINI * Brutal Deluxe Software * Date : Nov 2012 */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Dc_Shared.h"
|
||||
#include "Dc_Graphic.h"
|
||||
#include "Dc_Code.h"
|
||||
#include "Dc_Gif.h"
|
||||
#include "Dc_Memory.h"
|
||||
|
||||
/****************************************************/
|
||||
/* Main() : Fonction principale de l'application. */
|
||||
/****************************************************/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i, result, nb_file, verbose, nb_bank;
|
||||
char **tab_file;
|
||||
char file_extension[256];
|
||||
DWORD color_bg, color_frame;
|
||||
DWORD palette_16[16] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF};
|
||||
|
||||
/* Information */
|
||||
printf("MrSprite v1.0 (c) Brutal Deluxe 2012-2013.\n");
|
||||
|
||||
/* Init */
|
||||
verbose = 0;
|
||||
my_Memory(MEMORY_INIT,NULL,NULL);
|
||||
|
||||
/* Vérification des paramètres */
|
||||
if(argc < 3)
|
||||
{
|
||||
printf(" Usage : %s COMMAND <param_1> <param_2> <param_3>...\n",argv[0]);
|
||||
printf(" %s EXTRACT <sprite_file(s)_path> <background_color_RRGGBB> <frame_color_RRGGBB>.\n",argv[0]);
|
||||
printf(" ----\n");
|
||||
printf(" %s MIRROR <sprite_file(s)_path> <background_color_RRGGBB>.\n",argv[0]);
|
||||
printf(" %s FLIP <sprite_file(s)_path> <background_color_RRGGBB>.\n",argv[0]);
|
||||
printf(" %s ODD <sprite_file(s)_path> <background_color_RRGGBB>.\n",argv[0]);
|
||||
printf(" ----\n");
|
||||
printf(" %s UNIQUE <sprite_file(s)_path>.\n",argv[0]);
|
||||
printf(" %s RENAME <file(s)_path> <new_name>.\n",argv[0]);
|
||||
printf(" %s WALLPAPER <sprite_file(s)_path> <background_color_RRGGBB> <frame_color_RRGGBB>.\n",argv[0]);
|
||||
printf(" ----\n");
|
||||
printf(" %s CODE [-V] <sprite_file(s)_path> <background_color_RRGGBB> <color_0_RRGGBB> <color_1_RRGGBB>...\n",argv[0]);
|
||||
printf(" %s BANK <sprite_code(s)_path> <bank_object_name>.\n",argv[0]);
|
||||
printf(" ----\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
/**********************************************************************************/
|
||||
/** EXTRACT : Extrait tous les sprites d'une planche et les entoure d'un cadre **/
|
||||
/**********************************************************************************/
|
||||
if(argc == 5 && !my_stricmp(argv[1],"EXTRACT"))
|
||||
{
|
||||
/* Vérifie les paramètres */
|
||||
color_bg = DecodeRGBColor(argv[3]);
|
||||
color_frame = DecodeRGBColor(argv[4]);
|
||||
if(color_bg == 0xFFFFFFFF || color_frame == 0xFFFFFFFF)
|
||||
{
|
||||
printf(" Error : Can't convert color into a valid 0xRRGGBB format.\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* Récupère la liste des fichiers */
|
||||
tab_file = BuildFileTab(argv[2],&nb_file);
|
||||
if(tab_file == NULL)
|
||||
{
|
||||
printf(" Error : Can't build file list from '%s'.\n",argv[2]);
|
||||
return(2);
|
||||
}
|
||||
|
||||
/** Modifie l'image pour ajouter un cadre autour du Sprite + Création de l'image Sprite **/
|
||||
for(i=0; i<nb_file; i++)
|
||||
{
|
||||
printf(" - Processing file : '%s'\n",tab_file[i]);
|
||||
result = ExtractAllSprite(tab_file[i],color_bg,color_frame);
|
||||
}
|
||||
|
||||
/* Libération mémoire */
|
||||
mem_free_list(nb_file,tab_file);
|
||||
}
|
||||
|
||||
|
||||
/***************************************************/
|
||||
/** MIRROR : Retourne les Sprites Droite/Gauche **/
|
||||
/***************************************************/
|
||||
if(argc == 4 && !my_stricmp(argv[1],"MIRROR"))
|
||||
{
|
||||
/* Décodage des 16 couleurs du sprite */
|
||||
color_bg = DecodeRGBColor(argv[3]);
|
||||
if(color_bg == 0xFFFFFFFF)
|
||||
{
|
||||
printf(" Error : Can't convert color '%s' into a valid 0xRRGGBB format.\n",argv[3]);
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* Récupère la liste des fichiers */
|
||||
tab_file = BuildFileTab(argv[2],&nb_file);
|
||||
if(tab_file == NULL)
|
||||
{
|
||||
printf(" Error : Can't build file list from '%s'.\n",argv[2]);
|
||||
return(2);
|
||||
}
|
||||
|
||||
/** Création ses Sprites Mirroir **/
|
||||
for(i=0; i<nb_file; i++)
|
||||
{
|
||||
printf(" - Processing file : '%s'\n",tab_file[i]);
|
||||
result = CreateMirrorPicture(tab_file[i],color_bg);
|
||||
}
|
||||
|
||||
/* Libération mémoire */
|
||||
mem_free_list(nb_file,tab_file);
|
||||
}
|
||||
|
||||
|
||||
/********************************************/
|
||||
/** FLIP : Inverse les Sprites Haut/Base **/
|
||||
/********************************************/
|
||||
if(argc == 4 && !my_stricmp(argv[1],"FLIP"))
|
||||
{
|
||||
/* Décodage des 16 couleurs du sprite */
|
||||
color_bg = DecodeRGBColor(argv[3]);
|
||||
if(color_bg == 0xFFFFFFFF)
|
||||
{
|
||||
printf(" Error : Can't convert color '%s' into a valid 0xRRGGBB format.\n",argv[3]);
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* Récupère la liste des fichiers */
|
||||
tab_file = BuildFileTab(argv[2],&nb_file);
|
||||
if(tab_file == NULL)
|
||||
{
|
||||
printf(" Error : Can't build file list from '%s'.\n",argv[2]);
|
||||
return(2);
|
||||
}
|
||||
|
||||
/** Création ses Sprites Inversé **/
|
||||
for(i=0; i<nb_file; i++)
|
||||
{
|
||||
printf(" - Processing file : '%s'\n",tab_file[i]);
|
||||
result = CreateFlipPicture(tab_file[i],color_bg);
|
||||
}
|
||||
|
||||
/* Libération mémoire */
|
||||
mem_free_list(nb_file,tab_file);
|
||||
}
|
||||
|
||||
/*******************************************************/
|
||||
/** ODD : Génère les positions impaires des sprites **/
|
||||
/*******************************************************/
|
||||
if(argc == 4 && !my_stricmp(argv[1],"ODD"))
|
||||
{
|
||||
/* Décodage des 16 couleurs du sprite */
|
||||
color_bg = DecodeRGBColor(argv[3]);
|
||||
if(color_bg == 0xFFFFFFFF)
|
||||
{
|
||||
printf(" Error : Can't convert color '%s' into a valid 0xRRGGBB format.\n",argv[3]);
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* Récupère la liste des fichiers */
|
||||
tab_file = BuildFileTab(argv[2],&nb_file);
|
||||
if(tab_file == NULL)
|
||||
{
|
||||
printf(" Error : Can't build file list from '%s'.\n",argv[2]);
|
||||
return(2);
|
||||
}
|
||||
|
||||
/** Création ses Sprites Impaires **/
|
||||
for(i=0; i<nb_file; i++)
|
||||
{
|
||||
printf(" - Processing file : '%s'\n",tab_file[i]);
|
||||
result = CreateOddPicture(tab_file[i],color_bg);
|
||||
}
|
||||
|
||||
/* Libération mémoire */
|
||||
mem_free_list(nb_file,tab_file);
|
||||
}
|
||||
|
||||
/**********************************************/
|
||||
/** UNIQUE : Elimine les Sprites en double **/
|
||||
/**********************************************/
|
||||
if(argc == 3 && !my_stricmp(argv[1],"UNIQUE"))
|
||||
{
|
||||
/* Récupère la liste des fichiers */
|
||||
tab_file = BuildFileTab(argv[2],&nb_file);
|
||||
if(tab_file == NULL)
|
||||
{
|
||||
printf(" Error : Can't build file list from '%s'.\n",argv[2]);
|
||||
return(2);
|
||||
}
|
||||
|
||||
/** Supprime les Sprites en double **/
|
||||
result = RemoveDuplicatedPictures(nb_file,tab_file);
|
||||
|
||||
/* Libération mémoire */
|
||||
mem_free_list(nb_file,tab_file);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************/
|
||||
/** RENAME : Renomme les fichiers de facon incrémentale **/
|
||||
/***********************************************************/
|
||||
if(argc == 4 && !my_stricmp(argv[1],"RENAME"))
|
||||
{
|
||||
/* Récupère la liste des fichiers */
|
||||
tab_file = BuildFileTab(argv[2],&nb_file);
|
||||
if(tab_file == NULL)
|
||||
{
|
||||
printf(" Error : Can't build file list from '%s'.\n",argv[2]);
|
||||
return(2);
|
||||
}
|
||||
|
||||
/* Tri les fichiers */
|
||||
qsort(tab_file,nb_file,sizeof(char *),compare_filepath);
|
||||
|
||||
/* File extension */
|
||||
strcpy(file_extension,"gif");
|
||||
for(i=strlen(tab_file[0]); i>=0; i++)
|
||||
if(tab_file[0][i] == '.')
|
||||
{
|
||||
strcpy(file_extension,&tab_file[0][i+1]);
|
||||
break;
|
||||
}
|
||||
|
||||
/** Renomme les fichiers de facon incrémentale **/
|
||||
result = RenameAllFiles(nb_file,tab_file,argv[3],file_extension);
|
||||
|
||||
/* Libération mémoire */
|
||||
mem_free_list(nb_file,tab_file);
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************/
|
||||
/** WALLPAPER : Crée une grande image avec tous les Sprites **/
|
||||
/***************************************************************/
|
||||
if(argc == 5 && !my_stricmp(argv[1],"WALLPAPER"))
|
||||
{
|
||||
/* Vérifie les paramètres */
|
||||
color_bg = DecodeRGBColor(argv[3]);
|
||||
color_frame = DecodeRGBColor(argv[4]);
|
||||
if(color_bg == 0xFFFFFFFF || color_frame == 0xFFFFFFFF)
|
||||
{
|
||||
printf(" Error : Can't convert color into a valid 0xRRGGBB format.\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* Récupère la liste des fichiers */
|
||||
tab_file = BuildFileTab(argv[2],&nb_file);
|
||||
if(tab_file == NULL)
|
||||
{
|
||||
printf(" Error : Can't build file list from '%s'.\n",argv[2]);
|
||||
return(2);
|
||||
}
|
||||
|
||||
/** Création de l'image complète **/
|
||||
result = CreateWallPaper(nb_file,tab_file,color_bg,color_frame);
|
||||
|
||||
/* Libération mémoire */
|
||||
mem_free_list(nb_file,tab_file);
|
||||
}
|
||||
|
||||
//C:\svn_devzing\MrSprite\Debug>MrSprite.exe CODE D:\Project\StreetFighter\adon_spr_*.gif BAFECA 000000 443344 550000 555555 664400 777777 990000 996644 AA7700 BBBBBB CC4400 CC8866 CCAA00 DDAA88 DDCCAA
|
||||
/************************************************/
|
||||
/** CODE : Création du code pour les Sprites **/
|
||||
/************************************************/
|
||||
if(argc > 4 && !my_stricmp(argv[1],"CODE"))
|
||||
{
|
||||
/* Verbose */
|
||||
if(!my_stricmp(argv[2],"-V"))
|
||||
verbose = 1;
|
||||
|
||||
/* Décodage des 16 couleurs du sprite */
|
||||
color_bg = DecodeRGBColor(argv[verbose+3]);
|
||||
if(color_bg == 0xFFFFFFFF)
|
||||
{
|
||||
printf(" Error : Can't convert color '%s' into a valid 0xRRGGBB format.\n",argv[verbose+3]);
|
||||
return(1);
|
||||
}
|
||||
for(i=0; i<argc-verbose-4; i++)
|
||||
{
|
||||
palette_16[i] = DecodeRGBColor(argv[verbose+4+i]);
|
||||
if(palette_16[i] == 0xFFFFFFFF)
|
||||
{
|
||||
printf(" Error : Can't convert color '%s' into a valid 0xRRGGBB format.\n",argv[verbose+3+i]);
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Récupère la liste des fichiers */
|
||||
tab_file = BuildFileTab(argv[verbose+2],&nb_file);
|
||||
if(tab_file == NULL)
|
||||
{
|
||||
printf(" Error : Can't build file list from '%s'.\n",argv[verbose+2]);
|
||||
return(2);
|
||||
}
|
||||
|
||||
/** Création du code pour le Sprite **/
|
||||
for(i=0; i<nb_file; i++)
|
||||
{
|
||||
printf(" - Processing file : '%s'\n",tab_file[i]);
|
||||
result = CreateSpriteCode(tab_file[i],color_bg,argc-verbose-4,&palette_16[0],verbose);
|
||||
}
|
||||
|
||||
/* Libération mémoire */
|
||||
mem_free_list(nb_file,tab_file);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/** BANK : On regroupe les sources des sprites en BANK de 64 KB **/
|
||||
/*******************************************************************/
|
||||
if(4 == argc && !my_stricmp(argv[1],"BANK"))
|
||||
{
|
||||
/* Récupère la liste des fichiers source */
|
||||
tab_file = BuildFileTab(argv[2],&nb_file);
|
||||
if(tab_file == NULL)
|
||||
{
|
||||
printf(" Error : Can't build file list from '%s'.\n",argv[2]);
|
||||
return(2);
|
||||
}
|
||||
|
||||
/** Chargement / Compilation des fichiers sources **/
|
||||
for(i=0; i<nb_file; i++)
|
||||
{
|
||||
printf(" - Loading source file : '%s'\n",tab_file[i]);
|
||||
result = LoadSpriteCode(tab_file[i]);
|
||||
if(result)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Tri les Sprites par taille */
|
||||
my_Memory(MEMORY_SORT_CODEFILE,compare_codefile_size,NULL);
|
||||
|
||||
/** Création des Banc de code **/
|
||||
result = BuildCodeBank(argv[2],argv[3],&nb_bank);
|
||||
|
||||
/* Tri les Sprites par numero */
|
||||
my_Memory(MEMORY_SORT_CODEFILE,compare_codefile_num,NULL);
|
||||
|
||||
/** Création du fichier Source d'index **/
|
||||
result = CreateMainCode(argv[2],argv[3],nb_bank);
|
||||
|
||||
/* Libération mémoire */
|
||||
mem_free_list(nb_file,tab_file);
|
||||
}
|
||||
|
||||
/* Libération */
|
||||
my_Memory(MEMORY_FREE,NULL,NULL);
|
||||
|
||||
/* OK */
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*************************************************************************************/
|
Loading…
Reference in New Issue