diff --git a/HMT-Extractor Debug.launch b/HMT-Extractor Debug.launch
index a3c8184..002bef1 100644
--- a/HMT-Extractor Debug.launch
+++ b/HMT-Extractor Debug.launch
@@ -1,13 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
-
+
@@ -15,4 +34,6 @@
+
+
diff --git a/HMT-Extractor Release.launch b/HMT-Extractor Release.launch
index d5bc34f..10e9c9b 100644
--- a/HMT-Extractor Release.launch
+++ b/HMT-Extractor Release.launch
@@ -1,13 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
-
+
@@ -15,4 +32,5 @@
+
diff --git a/src/HMT_Parser.c b/src/HMT_Parser.c
index 0b7d0d4..0e0466c 100644
--- a/src/HMT_Parser.c
+++ b/src/HMT_Parser.c
@@ -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; imaterial_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; itexture_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;
+}
diff --git a/src/HMT_Parser.h b/src/HMT_Parser.h
index c949de4..907ae0f 100644
--- a/src/HMT_Parser.h
+++ b/src/HMT_Parser.h
@@ -36,7 +36,8 @@ typedef struct HMTMaterial {
float unknow1,unknow2;
int zero;
int hex_a;
- char *name[16];
+ char name[16];
+ //HMT_MATERIAL *next_mat;
}HMT_MATERIAL;
/**
@@ -73,8 +74,9 @@ typedef struct HMTTexture {
int palette_offset;
int textureName_offset;
unsigned long width, height;
- char *name[16];
+ char name[16];
RS_IMAGE image;
+ //HMT_TEXTURE *next_text;
}HMT_TEXTURE;
/**
@@ -92,6 +94,8 @@ typedef struct HMTFile {
/////////////////////////////
///// 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
diff --git a/src/HMT-Extractor.c b/src/Texture-Extractor.c
similarity index 58%
rename from src/HMT-Extractor.c
rename to src/Texture-Extractor.c
index 3b75b4a..46c7745 100644
--- a/src/HMT-Extractor.c
+++ b/src/Texture-Extractor.c
@@ -8,12 +8,28 @@
============================================================================
*/
-#include "HMT_Parser.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));
+
if (argc < 2) {
printf("No input file specified!\nCorrect syntax is:\n HMT-Extractor \n");
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;
}
diff --git a/src/HMT-Extractor.h b/src/Texture-Extractor.h
similarity index 65%
rename from src/HMT-Extractor.h
rename to src/Texture-Extractor.h
index 399ac6a..32c1f58 100644
--- a/src/HMT-Extractor.h
+++ b/src/Texture-Extractor.h
@@ -1,8 +1,9 @@
-#ifndef HMT_EXTRACTOR_H_
-#define HMT_EXTRACTOR_H_
+#ifndef TEXTURE_EXTRACTOR_H_
+#define TEXTURE_EXTRACTOR_H_
#include
#include
+#include
#include
#include
#include "HMT_Parser.h"