Organise main file
This commit is contained in:
parent
93d9689cfe
commit
cdfb989d48
@ -1,39 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<launchConfiguration type="org.eclipse.cdt.launch.applicationLaunchType">
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.AUTO_SOLIB" value="true"/>
|
|
||||||
<listAttribute key="org.eclipse.cdt.dsf.gdb.AUTO_SOLIB_LIST"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="gdb"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_ON_FORK" value="false"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.EXTERNAL_CONSOLE" value="false"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.GDB_INIT" value=".gdbinit"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.NON_STOP" value="false"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.REVERSE" value="false"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.REVERSE_MODE" value="UseSoftTrace"/>
|
|
||||||
<listAttribute key="org.eclipse.cdt.dsf.gdb.SOLIB_PATH"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.TRACEPOINT_MODE" value="TP_NORMAL_ONLY"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.internal.ui.launching.LocalApplicationCDebuggerTab.DEFAULTS_SET" value="true"/>
|
|
||||||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_ID" value="gdb"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="run"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_ARGUMENTS" value="gun_turret_HMT"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="${project_loc}\Debug\Texture-Extractor.exe"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="Texture-Extractor"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="cdt.managedbuild.config.gnu.cross.exe.debug.305633050"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.WORKING_DIRECTORY" value="${workspace_loc:Texture-Extractor/Debug}"/>
|
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
|
||||||
<listEntry value="/Texture-Extractor"/>
|
|
||||||
</listAttribute>
|
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
|
||||||
<listEntry value="4"/>
|
|
||||||
</listAttribute>
|
|
||||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
|
||||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
|
||||||
</listAttribute>
|
|
||||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="reserved-for-future-use"/> "/>
|
|
||||||
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
|
||||||
</launchConfiguration>
|
|
@ -1,36 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<launchConfiguration type="org.eclipse.cdt.launch.applicationLaunchType">
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.AUTO_SOLIB" value="true"/>
|
|
||||||
<listAttribute key="org.eclipse.cdt.dsf.gdb.AUTO_SOLIB_LIST"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="gdb"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_ON_FORK" value="false"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.EXTERNAL_CONSOLE" value="false"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.GDB_INIT" value=".gdbinit"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.NON_STOP" value="false"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.REVERSE" value="false"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.REVERSE_MODE" value="UseSoftTrace"/>
|
|
||||||
<listAttribute key="org.eclipse.cdt.dsf.gdb.SOLIB_PATH"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.TRACEPOINT_MODE" value="TP_NORMAL_ONLY"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.internal.ui.launching.LocalApplicationCDebuggerTab.DEFAULTS_SET" value="true"/>
|
|
||||||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_ID" value="gdb"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="run"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="${project_loc}\Release\Texture-Extractor.exe"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="Texture-Extractor"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="cdt.managedbuild.config.gnu.cross.exe.release.400013283"/>
|
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
|
||||||
<listEntry value="/Texture-Extractor"/>
|
|
||||||
</listAttribute>
|
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
|
||||||
<listEntry value="4"/>
|
|
||||||
</listAttribute>
|
|
||||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
|
||||||
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
|
|
||||||
</listAttribute>
|
|
||||||
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
|
||||||
</launchConfiguration>
|
|
@ -1,7 +1,7 @@
|
|||||||
#include "RS_images.h"
|
#include "RS_images.h"
|
||||||
|
|
||||||
|
|
||||||
void getPaletteFromFile(RS_IMAGE *img, FILE *f) {
|
int getPaletteFromFile(RS_IMAGE *img, FILE *f) {
|
||||||
int entries = img->paletteEntries;
|
int entries = img->paletteEntries;
|
||||||
|
|
||||||
switch (entries) {
|
switch (entries) {
|
||||||
@ -10,20 +10,24 @@ void getPaletteFromFile(RS_IMAGE *img, FILE *f) {
|
|||||||
fread(img->palette, sizeof(unsigned char), entries*3, f);
|
fread(img->palette, sizeof(unsigned char), entries*3, f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void getSamplesFromFile(RS_IMAGE *img, FILE *f) {
|
int getSamplesFromFile(RS_IMAGE *img, FILE *f) {
|
||||||
int sample_bits = img->sampleBits;
|
int sample_bits = img->sampleBits;
|
||||||
int size = img->width*img->height*div(sample_bits, 8).quot;
|
int size = img->width*img->height*div(sample_bits, 8).quot;
|
||||||
|
|
||||||
if (f->_bufsiz >= ftell(f)+size) {
|
if (f->_bufsiz >= ftell(f)+size) {
|
||||||
printf("WARNING! Please fix size/sample.");
|
printf("WARNING! Please fix size/sample.");
|
||||||
abort();
|
return EXCEPTION_DATATYPE_MISALIGNMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
img->samples = calloc(1, size);
|
img->samples = calloc(1, size);
|
||||||
fread(img->samples, size, 1, f);
|
fread(img->samples, size, 1, f);
|
||||||
if (img->type_ == 2) fread(img->samples, div(size, 4).quot, 1, f);
|
if (img->type_ == 2) fread(img->samples, div(size, 4).quot, 1, f);
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void decodePixels(RS_IMAGE *img) {
|
void decodePixels(RS_IMAGE *img) {
|
||||||
|
@ -26,7 +26,7 @@ typedef struct RSImage {
|
|||||||
int paletteEntries;
|
int paletteEntries;
|
||||||
unsigned char *pixels; /**< Image pixels list */
|
unsigned char *pixels; /**< Image pixels list */
|
||||||
unsigned char *samples; /**< Image samples list */
|
unsigned char *samples; /**< Image samples list */
|
||||||
unsigned char palette[256][3]; /**< Image palette definition */
|
unsigned char palette[256][3]; /**< Image palette definition */ //TODO: Create union struct type instead
|
||||||
}RS_IMAGE;
|
}RS_IMAGE;
|
||||||
|
|
||||||
typedef struct RSImage_desc {
|
typedef struct RSImage_desc {
|
||||||
@ -45,7 +45,7 @@ void unpack4To24bitsRGB(unsigned char *samples_tab, unsigned char *pixels_tab, i
|
|||||||
void unpack8To24bitsRGB(unsigned char *samples_tab, unsigned char *pixels_tab, int size, unsigned char pal[256][3]);
|
void unpack8To24bitsRGB(unsigned char *samples_tab, unsigned char *pixels_tab, int size, unsigned char pal[256][3]);
|
||||||
void useOddBytes(unsigned char *src, unsigned char *dst, int size);
|
void useOddBytes(unsigned char *src, unsigned char *dst, int size);
|
||||||
void decodePixels(RS_IMAGE *img);
|
void decodePixels(RS_IMAGE *img);
|
||||||
void getPaletteFromFile(RS_IMAGE *img, FILE *f);
|
int getPaletteFromFile(RS_IMAGE *img, FILE *f);
|
||||||
void getSamplesFromFile(RS_IMAGE *img, FILE *f);
|
int getSamplesFromFile(RS_IMAGE *img, FILE *f);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,35 +1,57 @@
|
|||||||
/*
|
/*
|
||||||
============================================================================
|
================================================================================
|
||||||
Name : HMT-Extractor.c
|
Name : Texture-Extractor.c
|
||||||
Author : JackCarterSmith
|
Author : JackCarterSmith
|
||||||
Version : 0.1
|
Version : 0.1
|
||||||
Copyright : LGPL
|
License : GPL-v3.0
|
||||||
Description : HMT textures extractor with enhanced function in C
|
Description : DAT textures extractor to PNG format with enhanced function in C
|
||||||
============================================================================
|
================================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Texture-Extractor.h"
|
#include "Texture-Extractor.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
char *filename = NULL;
|
|
||||||
FILE *testfile = NULL;
|
|
||||||
HMT_FILE *testhmt = calloc(1, sizeof(HMT_FILE));
|
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
// Init buffer vars
|
||||||
|
HMT_FILE *hmt_fdatas = NULL;
|
||||||
|
|
||||||
|
// Check if filenames arguments exist
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
printf("No input file specified!\nCorrect syntax is:\n HMT-Extractor <texture_file_hmt>\n");
|
printf("No input file specified!\nCorrect syntax is:\n HMT-Extractor <texture_file_hmt>\n");
|
||||||
return EXIT_FAILURE;
|
return EXCEPTION_NONCONTINUABLE; //TODO: implement own error codes system
|
||||||
}
|
}
|
||||||
filename = argv[1];
|
|
||||||
|
|
||||||
testfile = fopen(filename, "rb");
|
// Do the work
|
||||||
int op_result = parseHMTFile(testfile, testhmt);
|
hmt_fdatas = extractDatasFromHMT(argv[1]); //TODO: Manage multi inputs files
|
||||||
fclose(testfile);
|
exportTextures(hmt_fdatas, argv[1]);
|
||||||
|
purgeHMTFromMemory(hmt_fdatas); // Clean up memory (because I'm a good boy)
|
||||||
switch (op_result) {
|
|
||||||
case -1:
|
|
||||||
printf("[ERR] Wrong inputs values!\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void purgeHMTFromMemory(HMT_FILE *_f) {
|
||||||
|
free(_f->textures_list->image.pixels);
|
||||||
|
free(_f->textures_list->image.samples);
|
||||||
|
free(_f->materials_list);
|
||||||
|
free(_f->textures_list);
|
||||||
|
free(_f);
|
||||||
|
}
|
||||||
|
|
||||||
|
HMT_FILE *extractDatasFromHMT(char *hmt_filename) {
|
||||||
|
FILE *_hmtFile = fopen(hmt_filename, "rb");
|
||||||
|
HMT_FILE *hmt_fdatas = calloc(1, sizeof(HMT_FILE));
|
||||||
|
|
||||||
|
if (parseHMTFile(_hmtFile, hmt_fdatas) != EXIT_SUCCESS) purgeHMTFromMemory(hmt_fdatas);
|
||||||
|
|
||||||
|
fclose(_hmtFile);
|
||||||
|
|
||||||
|
return hmt_fdatas;
|
||||||
|
}
|
||||||
|
|
||||||
|
int exportTextures(HMT_FILE *hmt_f, char *filename) {
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int saveToPNG(RS_IMAGE *img, char *tex_name) {
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
@ -4,11 +4,14 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <zlib.h>
|
//#include <zlib.h>
|
||||||
#include <png.h>
|
#include <png.h>
|
||||||
#include "HMT_Parser.h"
|
#include "HMT_Parser.h"
|
||||||
#include "RS_images.h"
|
#include "RS_images.h"
|
||||||
|
|
||||||
int exportToPNM(FILE *f, RS_IMAGE *img);
|
void purgeHMTFromMemory(HMT_FILE *_f);
|
||||||
|
HMT_FILE *extractDatasFromHMT(char* hmt_filename);
|
||||||
|
int exportTextures(HMT_FILE *hmt_f, char *filename);
|
||||||
|
int saveToPNG(RS_IMAGE *img, char *tex_name);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user