Added material reading and a begin to hmt_parser
This commit is contained in:
parent
af1b3a593d
commit
de8c52e290
@ -1,13 +1,32 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<launchConfiguration type="org.eclipse.cdt.launch.applicationLaunchType">
|
<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"/>
|
<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.COREFILE_PATH" value=""/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="${project_loc}\Debug\HMT-Extractor.exe"/>
|
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_ID" value="gdb"/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="HMT-Extractor"/>
|
<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"/>
|
<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.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">
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||||
<listEntry value="/HMT-Extractor"/>
|
<listEntry value="/Texture-Extractor"/>
|
||||||
</listAttribute>
|
</listAttribute>
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||||
<listEntry value="4"/>
|
<listEntry value="4"/>
|
||||||
@ -15,4 +34,6 @@
|
|||||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||||
</listAttribute>
|
</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>
|
</launchConfiguration>
|
||||||
|
@ -1,13 +1,30 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<launchConfiguration type="org.eclipse.cdt.launch.applicationLaunchType">
|
<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"/>
|
<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.COREFILE_PATH" value=""/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="${project_loc}\Release\HMT-Extractor.exe"/>
|
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_ID" value="gdb"/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="HMT-Extractor"/>
|
<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"/>
|
<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"/>
|
<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">
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||||
<listEntry value="/HMT-Extractor"/>
|
<listEntry value="/Texture-Extractor"/>
|
||||||
</listAttribute>
|
</listAttribute>
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||||
<listEntry value="4"/>
|
<listEntry value="4"/>
|
||||||
@ -15,4 +32,5 @@
|
|||||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||||
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
|
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
|
||||||
</listAttribute>
|
</listAttribute>
|
||||||
|
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
||||||
</launchConfiguration>
|
</launchConfiguration>
|
||||||
|
@ -1,3 +1,53 @@
|
|||||||
#include "HMT-Extractor.h"
|
#include "HMT_Parser.h"
|
||||||
|
|
||||||
|
int parseHMTFile(FILE *hmt_src, HMT_FILE *dst) {
|
||||||
|
int result = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (hmt_src == NULL) return -1;
|
||||||
|
|
||||||
|
fseek(hmt_src, 0, SEEK_SET); //Rewind file at the start
|
||||||
|
fread(&(dst->material_count), 4, 1, hmt_src); // Extract first usefull datas
|
||||||
|
fread(&(dst->texture_offset), 4, 1, hmt_src);
|
||||||
|
|
||||||
|
// Read materials
|
||||||
|
printf("\n\nMaterials detected: %d\n", dst->material_count);
|
||||||
|
dst->materials_list = calloc(dst->material_count, sizeof(HMT_MATERIAL));
|
||||||
|
for (i=0; i<dst->material_count; i++) {
|
||||||
|
// Extract materials datas
|
||||||
|
if (readMaterial(&(dst->materials_list[i]), hmt_src) != 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read textures
|
||||||
|
fseek(hmt_src, dst->texture_offset, SEEK_SET);
|
||||||
|
fread(&(dst->texture_count), 4, 1, hmt_src);
|
||||||
|
printf("\n\nTextures detected: %d\n", dst->texture_count);
|
||||||
|
if (dst->texture_count > 0) {
|
||||||
|
dst->textures_list = calloc(dst->texture_count, sizeof(HMT_TEXTURE));
|
||||||
|
for (i=0; i<dst->texture_count; i++) {
|
||||||
|
// Extract textures datas
|
||||||
|
if (readTexture(&(dst->textures_list[i]), hmt_src) != 0) return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int readMaterial(HMT_MATERIAL *mat, FILE *hmt_src) {
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
if (mat == NULL || hmt_src == NULL) return -1;
|
||||||
|
|
||||||
|
fread(mat, sizeof(HMT_MATERIAL), 1, hmt_src);
|
||||||
|
|
||||||
|
if (mat->zero != 0 || mat->hex_a != 0x0A) printf("\n Uncommon file detected!\n");
|
||||||
|
printf("Material type: %d\nTexture index: %d\n", mat->type_, mat->texture_index);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int readTexture(HMT_TEXTURE *tex, FILE *hmt_src) {
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
@ -36,7 +36,8 @@ typedef struct HMTMaterial {
|
|||||||
float unknow1,unknow2;
|
float unknow1,unknow2;
|
||||||
int zero;
|
int zero;
|
||||||
int hex_a;
|
int hex_a;
|
||||||
char *name[16];
|
char name[16];
|
||||||
|
//HMT_MATERIAL *next_mat;
|
||||||
}HMT_MATERIAL;
|
}HMT_MATERIAL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,8 +74,9 @@ typedef struct HMTTexture {
|
|||||||
int palette_offset;
|
int palette_offset;
|
||||||
int textureName_offset;
|
int textureName_offset;
|
||||||
unsigned long width, height;
|
unsigned long width, height;
|
||||||
char *name[16];
|
char name[16];
|
||||||
RS_IMAGE image;
|
RS_IMAGE image;
|
||||||
|
//HMT_TEXTURE *next_text;
|
||||||
}HMT_TEXTURE;
|
}HMT_TEXTURE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,6 +94,8 @@ typedef struct HMTFile {
|
|||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
///// Declare functions /////
|
///// Declare functions /////
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
int exportToPNM(FILE *f, RS_IMAGE *img);
|
int parseHMTFile(FILE *hmt_src, HMT_FILE *dst);
|
||||||
|
int readMaterial(HMT_MATERIAL *mat, FILE *hmt_src);
|
||||||
|
int readTexture(HMT_TEXTURE *tex, FILE *hmt_src);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -8,12 +8,28 @@
|
|||||||
============================================================================
|
============================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "HMT_Parser.h"
|
#include "Texture-Extractor.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
char *filename = NULL;
|
||||||
|
FILE *testfile = NULL;
|
||||||
|
HMT_FILE *testhmt = calloc(1, sizeof(HMT_FILE));
|
||||||
|
|
||||||
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 EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
filename = argv[1];
|
||||||
|
|
||||||
|
testfile = fopen(filename, "rb");
|
||||||
|
int op_result = parseHMTFile(testfile, testhmt);
|
||||||
|
fclose(testfile);
|
||||||
|
|
||||||
|
switch (op_result) {
|
||||||
|
case -1:
|
||||||
|
printf("[ERR] Wrong inputs values!\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
@ -1,8 +1,9 @@
|
|||||||
#ifndef HMT_EXTRACTOR_H_
|
#ifndef TEXTURE_EXTRACTOR_H_
|
||||||
#define HMT_EXTRACTOR_H_
|
#define TEXTURE_EXTRACTOR_H_
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
#include <png.h>
|
#include <png.h>
|
||||||
#include "HMT_Parser.h"
|
#include "HMT_Parser.h"
|
Loading…
x
Reference in New Issue
Block a user