mirror of
https://github.com/simtactics/niotso.git
synced 2025-07-18 20:16:41 -04:00
Support for sprites was added to libiff.
Support for SPR# and SPR2 was added to iff2html. *NOTE: The default exporter used is the PNG one, since web browsers don't like targa. However, since there is a bug in my PNG exporter, I would recommend that you use the targa exporter for a precise representation of the loaded sprite frame(s). Feel free to fix the PNG exporter, btw :)
This commit is contained in:
parent
02dff475c8
commit
6c85920535
16 changed files with 1150 additions and 84 deletions
|
@ -17,6 +17,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include "iff.h"
|
||||
|
||||
#ifndef __inline
|
||||
|
@ -36,10 +37,11 @@ IFFFile * iff_create()
|
|||
return ptr;
|
||||
}
|
||||
|
||||
int iff_read_header(IFFFile * IFFFileInfo, const uint8_t * Buffer, unsigned FileSize)
|
||||
int iff_read_header(IFFFile * IFFFileInfo, const uint8_t * Buffer, unsigned FileSize, char *FileName)
|
||||
{
|
||||
unsigned offset;
|
||||
|
||||
|
||||
if(!FileSize) FileSize = ~0;
|
||||
else if(FileSize < 64)
|
||||
return 0;
|
||||
|
@ -47,6 +49,8 @@ int iff_read_header(IFFFile * IFFFileInfo, const uint8_t * Buffer, unsigned File
|
|||
if(memcmp(Buffer, Header_IFF, 60))
|
||||
return 0;
|
||||
memcpy(IFFFileInfo->Header, Buffer, 60);
|
||||
|
||||
IFFFileInfo->FileName = FileName;
|
||||
|
||||
offset = read_uint32be(Buffer+60);
|
||||
if(offset > FileSize - 28)
|
||||
|
@ -101,7 +105,8 @@ IFFChunkNode * iff_add_chunk(IFFFile * IFFFileInfo, int Position)
|
|||
node->NextChunk = ptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
IFFFileInfo->ChunkCount++;
|
||||
return ptr;
|
||||
}
|
||||
|
@ -147,4 +152,20 @@ int iff_enumerate_chunks(IFFFile * IFFFileInfo, const uint8_t * Buffer, unsigned
|
|||
BufferSize -= chunk->Chunk.Size;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
IFFChunk *iff_find_first_chunk(IFFFile *IFFFileInfo, const char *type, uint16_t id)
|
||||
{
|
||||
IFFChunkNode *currentNode = IFFFileInfo->FirstChunk;
|
||||
do
|
||||
{
|
||||
if (type == NULL || !memcmp(type, currentNode->Chunk.Type, 4) &&
|
||||
(id == 0 || id == currentNode->Chunk.ChunkID))
|
||||
return ¤tNode->Chunk;
|
||||
|
||||
currentNode = currentNode->NextChunk;
|
||||
}
|
||||
while (currentNode != IFFFileInfo->LastChunk);
|
||||
|
||||
return NULL;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue