mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-03-15 14:51:21 +00:00
Added prerelease version of libvitaboy 1.0.1
This commit is contained in:
parent
432d12397c
commit
a4a7b82bb7
10 changed files with 281 additions and 96 deletions
|
@ -30,7 +30,7 @@ int main(int argc, char *argv[]){
|
|||
unsigned chunkcount, chunk = 0;
|
||||
IFFFile * IFFFileInfo;
|
||||
IFFChunkNode * ChunkNode;
|
||||
|
||||
|
||||
if(argc == 1 || !strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")){
|
||||
printf("Usage: iffexport [-f] infile OutDirectory\n"
|
||||
"Export the resources of an EA IFF file.\n"
|
||||
|
@ -41,7 +41,7 @@ int main(int argc, char *argv[]){
|
|||
"Home page: <http://www.niotso.org/>\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if(argc >= 4 && !strcmp(argv[1], "-f")){
|
||||
overwrite++;
|
||||
InFile = argv[2];
|
||||
|
@ -79,7 +79,7 @@ int main(int argc, char *argv[]){
|
|||
return -1;
|
||||
}
|
||||
CloseHandle(hFile);
|
||||
|
||||
|
||||
/****
|
||||
** Load header information
|
||||
*/
|
||||
|
@ -102,10 +102,10 @@ int main(int argc, char *argv[]){
|
|||
printf("%sChunk data is corrupt.", "iffexport: error: ");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
chunkcount = IFFFileInfo->ChunkCount;
|
||||
printf("This IFF file contains %u chunks.\n\nExporting\n", chunkcount);
|
||||
|
||||
|
||||
/****
|
||||
** Extract each entry
|
||||
*/
|
||||
|
@ -137,6 +137,6 @@ int main(int argc, char *argv[]){
|
|||
WriteFile(hFile, ChunkNode->Chunk.Data, ChunkNode->Chunk.Size-76, &bytestransferred, NULL);
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,8 +1,14 @@
|
|||
libvitaboy 1.0.1 (2012-03-10) Fatbag
|
||||
|
||||
* Corrected the BlendVertices function; blend vertices tug real vertices, not the other way around
|
||||
* Interleaved all vertex data (coords, texcoords, normals, blend weights) into the VertexData array
|
||||
|
||||
|
||||
libvitaboy 1.0.0 (2012-03-04) Fatbag
|
||||
|
||||
* first stable release
|
||||
* read support for ANIM, APR, BND, COL, HAG, MESH, OFT, PO, SKEL
|
||||
* working rendering and animation of characters in OpenGL
|
||||
* basic keyboard controls
|
||||
* support for environments: MinGW
|
||||
* support for platforms: i686, x86-64
|
||||
* First stable release
|
||||
* Read support for ANIM, APR, BND, COL, HAG, MESH, OFT, PO, SKEL
|
||||
* Working rendering and animation of characters in OpenGL
|
||||
* Basic keyboard controls
|
||||
* Support for environments: MinGW
|
||||
* Support for platforms: i686, x86-64
|
|
@ -28,7 +28,7 @@ Formats include:
|
|||
|
||||
1. What this library will do for you
|
||||
|
||||
You can use this library to render a character in a fixed location.
|
||||
You can use this library to render a character in a predetermined location.
|
||||
|
||||
|
||||
2. Compiling
|
||||
|
|
|
@ -61,9 +61,12 @@ bool active=true;
|
|||
bool fullscreen=false;
|
||||
|
||||
float zoom = -10;
|
||||
struct BasicVertex_t {
|
||||
float x, y, z;
|
||||
};
|
||||
struct CharacterPlacement_t {
|
||||
Vertex_t Translation;
|
||||
Vertex_t Rotation;
|
||||
BasicVertex_t Translation;
|
||||
BasicVertex_t Rotation;
|
||||
};
|
||||
CharacterPlacement_t Character = {{0,-3,0}, {0,0,0}};
|
||||
|
||||
|
@ -197,29 +200,29 @@ void TransformVertices(Bone_t& Bone)
|
|||
}
|
||||
|
||||
if(BoneIndex < Mesh.BindingCount){
|
||||
for(unsigned i=0; i<Mesh.BoneBindings[BoneIndex].FixedVertexCount; i++){
|
||||
unsigned VertexIndex = Mesh.BoneBindings[BoneIndex].FirstFixedVertex + i;
|
||||
for(unsigned i=0; i<Mesh.BoneBindings[BoneIndex].RealVertexCount; i++){
|
||||
unsigned VertexIndex = Mesh.BoneBindings[BoneIndex].FirstRealVertex + i;
|
||||
Vertex_t& RelativeVertex = Mesh.VertexData[VertexIndex];
|
||||
Vertex_t& AbsoluteVertex = Mesh.TransformedVertexData[VertexIndex];
|
||||
|
||||
glTranslatef(RelativeVertex.x, RelativeVertex.y, RelativeVertex.z);
|
||||
glTranslatef(RelativeVertex.Coord.x, RelativeVertex.Coord.y, RelativeVertex.Coord.z);
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX, Matrix);
|
||||
AbsoluteVertex.x = Matrix[12];
|
||||
AbsoluteVertex.y = Matrix[13];
|
||||
AbsoluteVertex.z = Matrix[14];
|
||||
glTranslatef(-RelativeVertex.x, -RelativeVertex.y, -RelativeVertex.z);
|
||||
AbsoluteVertex.Coord.x = Matrix[12];
|
||||
AbsoluteVertex.Coord.y = Matrix[13];
|
||||
AbsoluteVertex.Coord.z = Matrix[14];
|
||||
glTranslatef(-RelativeVertex.Coord.x, -RelativeVertex.Coord.y, -RelativeVertex.Coord.z);
|
||||
}
|
||||
for(unsigned i=0; i<Mesh.BoneBindings[BoneIndex].BlendedVertexCount; i++){
|
||||
unsigned VertexIndex = Mesh.FixedVertexCount + Mesh.BoneBindings[BoneIndex].FirstBlendedVertex + i;
|
||||
for(unsigned i=0; i<Mesh.BoneBindings[BoneIndex].BlendVertexCount; i++){
|
||||
unsigned VertexIndex = Mesh.RealVertexCount + Mesh.BoneBindings[BoneIndex].FirstBlendVertex + i;
|
||||
Vertex_t& RelativeVertex = Mesh.VertexData[VertexIndex];
|
||||
Vertex_t& AbsoluteVertex = Mesh.TransformedVertexData[VertexIndex];
|
||||
|
||||
glTranslatef(RelativeVertex.x, RelativeVertex.y, RelativeVertex.z);
|
||||
glTranslatef(RelativeVertex.Coord.x, RelativeVertex.Coord.y, RelativeVertex.Coord.z);
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX, Matrix);
|
||||
AbsoluteVertex.x = Matrix[12];
|
||||
AbsoluteVertex.y = Matrix[13];
|
||||
AbsoluteVertex.z = Matrix[14];
|
||||
glTranslatef(-RelativeVertex.x, -RelativeVertex.y, -RelativeVertex.z);
|
||||
AbsoluteVertex.Coord.x = Matrix[12];
|
||||
AbsoluteVertex.Coord.y = Matrix[13];
|
||||
AbsoluteVertex.Coord.z = Matrix[14];
|
||||
glTranslatef(-RelativeVertex.Coord.x, -RelativeVertex.Coord.y, -RelativeVertex.Coord.z);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -238,19 +241,19 @@ void BlendVertices()
|
|||
{
|
||||
for(unsigned i=0; i<MeshCount; i++){
|
||||
Mesh_t& Mesh = Meshes[i];
|
||||
for(unsigned i=0; i<Mesh.BlendedVertexCount; i++){
|
||||
unsigned Weight = Mesh.BlendData[i].Weight;
|
||||
Vertex_t& BlendedVertex = Mesh.TransformedVertexData[Mesh.FixedVertexCount + i];
|
||||
Vertex_t& FixedVertex = Mesh.TransformedVertexData[Mesh.FixedVertexCount + i];
|
||||
BlendedVertex.x =
|
||||
Weight * BlendedVertex.x +
|
||||
(1-Weight) * FixedVertex.x;
|
||||
BlendedVertex.y =
|
||||
Weight * BlendedVertex.y +
|
||||
(1-Weight) * FixedVertex.y;
|
||||
BlendedVertex.z =
|
||||
Weight * BlendedVertex.z +
|
||||
(1-Weight) * FixedVertex.z;
|
||||
for(unsigned i=0; i<Mesh.BlendVertexCount; i++){
|
||||
Vertex_t& BlendVertex = Mesh.TransformedVertexData[Mesh.RealVertexCount + i];
|
||||
float Weight = BlendVertex.BlendData.Weight;
|
||||
Vertex_t& RealVertex = Mesh.TransformedVertexData[BlendVertex.BlendData.OtherVertex];
|
||||
RealVertex.Coord.x =
|
||||
Weight * BlendVertex.Coord.x +
|
||||
(1-Weight) * RealVertex.Coord.x;
|
||||
RealVertex.Coord.y =
|
||||
Weight * BlendVertex.Coord.y +
|
||||
(1-Weight) * RealVertex.Coord.y;
|
||||
RealVertex.Coord.z =
|
||||
Weight * BlendVertex.Coord.z +
|
||||
(1-Weight) * RealVertex.Coord.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -271,10 +274,8 @@ void DrawMeshes()
|
|||
|
||||
for(unsigned i=0; i<MeshCount; i++){
|
||||
glBindTexture(GL_TEXTURE_2D, texture[Mesh_UseTexture[i]]);
|
||||
glVertexPointer(3, GL_FLOAT, offsetof(Vertex_t, y)-offsetof(Vertex_t, x)-sizeof(float),
|
||||
Meshes[i].TransformedVertexData);
|
||||
glTexCoordPointer(2, GL_FLOAT, offsetof(TextureVertex_t, v)-offsetof(TextureVertex_t, u)-sizeof(float),
|
||||
Meshes[i].TransformedTextureData);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(Vertex_t), &Meshes[i].TransformedVertexData[0].Coord);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex_t), &Meshes[i].TransformedVertexData[0].TextureCoord);
|
||||
glDrawElements(GL_TRIANGLES, Meshes[i].FaceCount*3, GL_UNSIGNED_INT, Meshes[i].FaceData);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,12 @@ class VBFile_t {
|
|||
inline void seekto(unsigned offset){
|
||||
Position = Buffer+offset;
|
||||
}
|
||||
inline void seekahead(unsigned count){
|
||||
Position += count;
|
||||
}
|
||||
inline void seekback(unsigned count){
|
||||
Position -= count;
|
||||
}
|
||||
|
||||
inline uint32_t readint32(){
|
||||
uint32_t value = (uint32_t)((Position[0]<<(8*3)) | (Position[1]<<(8*2)) | (Position[2]<<(8*1)) | (Position[3]<<(8*0)));
|
||||
|
@ -261,25 +267,42 @@ struct TextureVertex_t {
|
|||
float u, v;
|
||||
};
|
||||
|
||||
struct Vertex_t {
|
||||
struct Coord_t {
|
||||
float x, y, z;
|
||||
};
|
||||
|
||||
struct TextureCoord_t {
|
||||
float u, v;
|
||||
};
|
||||
|
||||
struct NormalCoord_t {
|
||||
float x, y, z;
|
||||
};
|
||||
|
||||
struct BlendData_t {
|
||||
float Weight;
|
||||
unsigned OtherVertex;
|
||||
};
|
||||
|
||||
struct Vertex_t {
|
||||
Coord_t Coord;
|
||||
TextureCoord_t TextureCoord;
|
||||
NormalCoord_t NormalCoord;
|
||||
|
||||
unsigned BoneIndex;
|
||||
BlendData_t BlendData;
|
||||
};
|
||||
|
||||
struct Face_t {
|
||||
unsigned VertexA, VertexB, VertexC;
|
||||
};
|
||||
|
||||
struct BoneBinding_t {
|
||||
unsigned BoneIndex;
|
||||
unsigned FirstFixedVertex;
|
||||
unsigned FixedVertexCount;
|
||||
unsigned FirstBlendedVertex;
|
||||
unsigned BlendedVertexCount;
|
||||
};
|
||||
|
||||
struct BlendData_t {
|
||||
float Weight;
|
||||
unsigned OtherVertex;
|
||||
unsigned FirstRealVertex;
|
||||
unsigned RealVertexCount;
|
||||
unsigned FirstBlendVertex;
|
||||
unsigned BlendVertexCount;
|
||||
};
|
||||
|
||||
struct Mesh_t {
|
||||
|
@ -290,16 +313,11 @@ struct Mesh_t {
|
|||
Face_t * FaceData;
|
||||
uint32_t BindingCount;
|
||||
BoneBinding_t * BoneBindings;
|
||||
uint32_t FixedVertexCount;
|
||||
TextureVertex_t * TextureVertexData;
|
||||
uint32_t BlendedVertexCount;
|
||||
BlendData_t * BlendData;
|
||||
uint32_t RealVertexCount;
|
||||
uint32_t BlendVertexCount;
|
||||
uint32_t TotalVertexCount;
|
||||
Vertex_t * VertexData;
|
||||
Vertex_t * VertexNorms;
|
||||
Vertex_t * TransformedVertexData;
|
||||
Vertex_t * TransformedVertexNorms;
|
||||
TextureVertex_t * TransformedTextureData;
|
||||
};
|
||||
|
||||
void ReadMesh(Mesh_t& Mesh);
|
||||
|
|
|
@ -43,52 +43,56 @@ void ReadMesh(Mesh_t& Mesh){
|
|||
printf("BindingCount: %u\n", Mesh.BindingCount);
|
||||
for(unsigned i=0; i<Mesh.BindingCount; i++){
|
||||
Mesh.BoneBindings[i].BoneIndex = VBFile.readint32();
|
||||
Mesh.BoneBindings[i].FirstFixedVertex = VBFile.readint32();
|
||||
Mesh.BoneBindings[i].FixedVertexCount = VBFile.readint32();
|
||||
Mesh.BoneBindings[i].FirstBlendedVertex = VBFile.readint32();
|
||||
Mesh.BoneBindings[i].BlendedVertexCount = VBFile.readint32();
|
||||
Mesh.BoneBindings[i].FirstRealVertex = VBFile.readint32();
|
||||
Mesh.BoneBindings[i].RealVertexCount = VBFile.readint32();
|
||||
Mesh.BoneBindings[i].FirstBlendVertex = VBFile.readint32();
|
||||
Mesh.BoneBindings[i].BlendVertexCount = VBFile.readint32();
|
||||
}
|
||||
|
||||
Mesh.FixedVertexCount = VBFile.readint32();
|
||||
printf("FixedVertexCount: %u\n", Mesh.FixedVertexCount);
|
||||
Mesh.TextureVertexData = (TextureVertex_t*) malloc(Mesh.FixedVertexCount * sizeof(TextureVertex_t));
|
||||
for(unsigned i=0; i<Mesh.FixedVertexCount; i++){
|
||||
Mesh.TextureVertexData[i].u = VBFile.readfloat();
|
||||
Mesh.TextureVertexData[i].v = VBFile.readfloat();
|
||||
Mesh.RealVertexCount = VBFile.readint32();
|
||||
printf("RealVertexCount: %u\n", Mesh.RealVertexCount);
|
||||
TextureVertex_t * TextureVertexData = (TextureVertex_t*) malloc(Mesh.RealVertexCount * sizeof(TextureVertex_t));
|
||||
for(unsigned i=0; i<Mesh.RealVertexCount; i++){
|
||||
TextureVertexData[i].u = VBFile.readfloat();
|
||||
TextureVertexData[i].v = VBFile.readfloat();
|
||||
}
|
||||
|
||||
Mesh.BlendedVertexCount = VBFile.readint32();
|
||||
printf("BlendedVertexCount: %u\n", Mesh.BlendedVertexCount);
|
||||
Mesh.BlendData = (BlendData_t*) malloc(Mesh.BlendedVertexCount * sizeof(BlendData_t));
|
||||
for(unsigned i=0; i<Mesh.BlendedVertexCount; i++){
|
||||
Mesh.BlendData[i].Weight = (float)VBFile.readint32()/0x8000;
|
||||
Mesh.BlendData[i].OtherVertex = VBFile.readint32();
|
||||
Mesh.BlendVertexCount = VBFile.readint32();
|
||||
printf("BlendVertexCount: %u\n", Mesh.BlendVertexCount);
|
||||
BlendData_t * BlendData = (BlendData_t*) malloc(Mesh.BlendVertexCount * sizeof(BlendData_t));
|
||||
for(unsigned i=0; i<Mesh.BlendVertexCount; i++){
|
||||
BlendData[i].Weight = (float)VBFile.readint32()/0x8000;
|
||||
BlendData[i].OtherVertex = VBFile.readint32();
|
||||
}
|
||||
|
||||
Mesh.TotalVertexCount = VBFile.readint32();
|
||||
printf("TotalVertexCount: %u\n", Mesh.TotalVertexCount);
|
||||
Mesh.VertexData = (Vertex_t*) malloc(Mesh.TotalVertexCount * sizeof(Vertex_t));
|
||||
Mesh.VertexNorms = (Vertex_t*) malloc(Mesh.TotalVertexCount * sizeof(Vertex_t));
|
||||
Mesh.TransformedVertexData = (Vertex_t*) malloc(Mesh.TotalVertexCount * sizeof(Vertex_t));
|
||||
Mesh.TransformedVertexNorms = (Vertex_t*) malloc(Mesh.TotalVertexCount * sizeof(Vertex_t));
|
||||
Mesh.TransformedTextureData = (TextureVertex_t*) malloc(Mesh.TotalVertexCount * sizeof(Vertex_t));
|
||||
for(unsigned i=0; i<Mesh.TotalVertexCount; i++){
|
||||
Mesh.VertexData[i].x = VBFile.readfloat();
|
||||
Mesh.VertexData[i].y = VBFile.readfloat();
|
||||
Mesh.VertexData[i].z = VBFile.readfloat();
|
||||
Mesh.VertexNorms[i].x = VBFile.readfloat();
|
||||
Mesh.VertexNorms[i].y = VBFile.readfloat();
|
||||
Mesh.VertexNorms[i].z = VBFile.readfloat();
|
||||
Mesh.VertexData[i].Coord.x = VBFile.readfloat();
|
||||
Mesh.VertexData[i].Coord.y = VBFile.readfloat();
|
||||
Mesh.VertexData[i].Coord.z = VBFile.readfloat();
|
||||
Mesh.TransformedVertexData[i].NormalCoord.x = VBFile.readfloat();
|
||||
Mesh.TransformedVertexData[i].NormalCoord.y = VBFile.readfloat();
|
||||
Mesh.TransformedVertexData[i].NormalCoord.z = VBFile.readfloat();
|
||||
|
||||
if(i<Mesh.FixedVertexCount){
|
||||
if(i<Mesh.RealVertexCount){
|
||||
//Fixed vertex
|
||||
Mesh.TransformedTextureData[i].u = Mesh.TextureVertexData[i].u;
|
||||
Mesh.TransformedTextureData[i].v = Mesh.TextureVertexData[i].v;
|
||||
Mesh.TransformedVertexData[i].TextureCoord.u = TextureVertexData[i].u;
|
||||
Mesh.TransformedVertexData[i].TextureCoord.v = TextureVertexData[i].v;
|
||||
}else{
|
||||
//Blended vertex; inherit
|
||||
TextureVertex_t& Parent = Mesh.TextureVertexData[Mesh.BlendData[i-Mesh.FixedVertexCount].OtherVertex];
|
||||
Mesh.TransformedTextureData[i].u = Parent.u;
|
||||
Mesh.TransformedTextureData[i].v = Parent.v;
|
||||
//Blended vertex
|
||||
Mesh.TransformedVertexData[i].BlendData.Weight = BlendData[i-Mesh.RealVertexCount].Weight;
|
||||
Mesh.TransformedVertexData[i].BlendData.OtherVertex = BlendData[i-Mesh.RealVertexCount].OtherVertex;
|
||||
|
||||
//Inherit texture coordinates
|
||||
TextureVertex_t& Parent = TextureVertexData[Mesh.TransformedVertexData[i].BlendData.OtherVertex];
|
||||
Mesh.TransformedVertexData[i].TextureCoord.u = Parent.u;
|
||||
Mesh.TransformedVertexData[i].TextureCoord.v = Parent.v;
|
||||
}
|
||||
}
|
||||
|
||||
free(TextureVertexData);
|
||||
free(BlendData);
|
||||
}
|
|
@ -1 +1,3 @@
|
|||
add_subdirectory(FARDive)
|
||||
add_subdirectory(FARDive)
|
||||
add_subdirectory(iff2html)
|
||||
add_subdirectory(misc)
|
0
Tools/iff2html/CMakeLists.txt
Normal file
0
Tools/iff2html/CMakeLists.txt
Normal file
109
Tools/iff2html/iff2html.c
Normal file
109
Tools/iff2html/iff2html.c
Normal file
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
iff2html.c - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <windows.h>
|
||||
#include "iff.h"
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
HANDLE hFile;
|
||||
int overwrite = 0;
|
||||
char *InFile, *OutDirectory;
|
||||
HANDLE ProcessHeap = GetProcessHeap();
|
||||
DWORD FileSize;
|
||||
DWORD bytestransferred = 0;
|
||||
uint8_t * IFFData;
|
||||
unsigned chunkcount, chunk = 0;
|
||||
IFFFile * IFFFileInfo;
|
||||
IFFChunkNode * ChunkNode;
|
||||
|
||||
if(argc == 1 || !strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")){
|
||||
printf("Usage: iff2html [-f] infile outfile\n"
|
||||
"Produce an HTML webpage describing an EA IFF file.\n"
|
||||
"Use -f to force overwriting without confirmation.\n"
|
||||
"\n"
|
||||
"Report bugs to <X-Fi6@phppoll.org>.\n"
|
||||
"iff2html is maintained by the Niotso project.\n"
|
||||
"Home page: <http://www.niotso.org/>\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(argc >= 4 && !strcmp(argv[1], "-f")){
|
||||
overwrite++;
|
||||
InFile = argv[2];
|
||||
OutDirectory = argv[3];
|
||||
}else{
|
||||
InFile = argv[1];
|
||||
OutDirectory = argv[2];
|
||||
}
|
||||
|
||||
/****
|
||||
** Open the file and read in entire contents to memory
|
||||
*/
|
||||
|
||||
hFile = CreateFile(InFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
||||
if(hFile == INVALID_HANDLE_VALUE){
|
||||
if(GetLastError() == ERROR_FILE_NOT_FOUND){
|
||||
printf("%sThe specified input file does not exist.", "iff2html: error: ");
|
||||
return -1;
|
||||
}
|
||||
printf("%sThe input file could not be opened for reading.", "iff2html: error: ");
|
||||
return -1;
|
||||
}
|
||||
FileSize = GetFileSize(hFile, NULL);
|
||||
if(FileSize < 64){
|
||||
printf("%sNot a valid IFF file.", "iff2html: error: ");
|
||||
return -1;
|
||||
}
|
||||
IFFData = HeapAlloc(ProcessHeap, HEAP_NO_SERIALIZE, FileSize);
|
||||
if(IFFData == NULL){
|
||||
printf("%sMemory for this file could not be allocated.", "iff2html: error: ");
|
||||
return -1;
|
||||
}
|
||||
if(!ReadFile(hFile, IFFData, FileSize, &bytestransferred, NULL) || bytestransferred != FileSize){
|
||||
printf("%sThe input file could not be read.", "iff2html: error: ");
|
||||
return -1;
|
||||
}
|
||||
CloseHandle(hFile);
|
||||
|
||||
/****
|
||||
** Load header information
|
||||
*/
|
||||
|
||||
IFFFileInfo = iff_create();
|
||||
if(IFFFileInfo == NULL){
|
||||
printf("%sMemory for this file could not be allocated.", "iff2html: error: ");
|
||||
return -1;
|
||||
}
|
||||
if(!iff_read_header(IFFFileInfo, IFFData, FileSize)){
|
||||
printf("%sNot a valid IFF file.", "iff2html: error: ");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/****
|
||||
** Load entry information
|
||||
*/
|
||||
|
||||
if(!iff_enumerate_chunks(IFFFileInfo, IFFData+64, FileSize-64)){
|
||||
printf("%sChunk data is corrupt.", "iff2html: error: ");
|
||||
return -1;
|
||||
}
|
||||
|
||||
chunkcount = IFFFileInfo->ChunkCount;
|
||||
|
||||
return 0;
|
||||
}
|
45
Tools/iff2html/output.html
Normal file
45
Tools/iff2html/output.html
Normal file
|
@ -0,0 +1,45 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="Content-Style-Type" content="text/css; charset=utf-8" />
|
||||
<meta http-equiv="Content-Language" content="en" />
|
||||
<meta name="description" content="behavior.iff (iff2html)" />
|
||||
<title>behavior.iff (iff2html)</title>
|
||||
<style type="text/css" media="all">
|
||||
html, body {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
a:link, a:visited, a:hover; a:active { color: #00f; }
|
||||
a:link, a:visited { text-decoration: none; }
|
||||
a:hover, a:active { text-decoration: underline; }
|
||||
|
||||
#toc {
|
||||
display: table-cell;
|
||||
margin-top: 1em;
|
||||
background: #eee; border: 1px solid #bbb;
|
||||
padding: .25em;
|
||||
}
|
||||
#toc ul {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
}
|
||||
ul ul {
|
||||
padding: 2em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>behavior.iff</h1>
|
||||
<div style="border-left: 2px solid #888; padding-left: 4px; margin-bottom: 1em">
|
||||
<div>9809b96803833f2891ddd31e474795a9 (md5), 42.4kB (43,446 bytes)</div>
|
||||
<div>Dumped by iff2html.</div></div>
|
||||
|
||||
<div id="toc"><div><b>Contents</b> – x chunks</div>
|
||||
<ul>
|
||||
<li><a href="#">1 [STR#] (00DD) – neighbor data labels</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Reference in a new issue