org.gamenet.application.mm8leveleditor.mm6
Class MM6SpritesLodEntry

java.lang.Object
  extended byorg.gamenet.application.mm8leveleditor.lod.LodEntry
      extended byorg.gamenet.application.mm8leveleditor.mm6.MM6SpritesLodEntry
All Implemented Interfaces:
Comparable, LodResource, TGADataProducer

public class MM6SpritesLodEntry
extends LodEntry
implements TGADataProducer


Nested Class Summary
protected  class MM6SpritesLodEntry.NullOutputStream
           
 class MM6SpritesLodEntry.ZeroCompressionTableEntry
           
 
Field Summary
private static int DATA_CONTENT_UNCOMPRESSED_SIZE__DATA_HEADER_OFFSET
           
protected static int DATA_HEADER_LENGTH
           
protected static int DATA_NAME__DATA_HEADER_MAX_LENGTH
           
protected static int DATA_NAME__DATA_HEADER_OFFSET
           
protected static int DATA_SEGMENT_LENGTH__ENTRY_HEADER_OFFSET
           
protected static int DATA_SEGMENT_OFFSET__ENTRY_HEADER_OFFSET
           
protected static int ENTRY_NAME__ENTRY_HEADER_MAX_LENGTH
           
protected static int ENTRY_NAME__ENTRY_HEADER_OFFSET
           
protected static int PALETTE_NUMBER__DATA_HEADER_OFFSET
           
protected static int TGA_BYTE_HEIGHT__DATA_HEADER_OFFSET
           
protected static int TGA_BYTE_WIDTH__DATA_HEADER_OFFSET
           
protected  Extractor theFileExtractor
           
protected  Extractor theLodFileExtractor
           
protected  Extractor thePassThroughLodFileExtractor
           
private static int UNKNOWN__DATA_HEADER_OFFSET
           
private static int ZERO_COMPRESSION_LINE_DATA_END_BYTE_OFFSET
           
private static int ZERO_COMPRESSION_LINE_DATA_OFFSET_OFFSET
           
private static int ZERO_COMPRESSION_LINE_DATA_START_BYTE_OFFSET
           
private static int ZERO_COMPRESSION_TABLE__DATA_HEADER_OFFSET
           
private static int ZERO_COMPRESSION_TABLE_DATA_SIZE
           
 
Fields inherited from class org.gamenet.application.mm8leveleditor.lod.LodEntry
dataHeader, entryHeader, entryOffset, lodFile
 
Constructor Summary
MM6SpritesLodEntry(LodFile lodFile, long headerOffset)
           
 
Method Summary
protected  void computeDataBasedOffsets()
           
protected  void computeEntryBasedOffsets()
           
 int getByteHeight()
           
 int getByteWidth()
           
 byte[] getData()
           
protected  int getDataHeaderLength()
           
protected  long getDataHeaderOffset()
           
protected  int getDataLength()
           
 String getDataName()
           
protected  int getDataNameMaxLength()
           
 long getDataOffset()
           
protected  String getDataType()
           
protected  long getDecompressedSize()
           
 String getEntryName()
           
protected  Extractor getExtractor()
           
 String getFileName()
           
protected  String getFileType()
           
 FormatConverter getFormatConverter()
           
 String getFormatConverterFileType()
           
protected  int getNewWrittenDataContentLength(LodResource lodResourceDataSource)
           
protected  long getOffsetInDataHeaderForDataContentUncompressedLength()
           
protected  int getOffsetInDataHeaderForDataName()
           
protected  int getOffsetInDataHeaderForPaletteNumber()
           
protected  int getOffsetInDataHeaderForTGAByteHeight()
           
protected  int getOffsetInDataHeaderForTGAByteWidth()
           
protected  int getOffsetInEntryHeaderForDataSegmentLength()
           
protected  int getOffsetInEntryHeaderForDataSegmentOffset()
           
 int[] getPalette()
           
protected  long getPaletteNumber()
           
 String getResourceType()
           
 String getTextDescription()
           
protected  int getUpdatedWrittenDataContentLength(LodResource lodResourceDataSource)
           
 MM6SpritesLodEntry.ZeroCompressionTableEntry[] getZeroCompressionTable(byte[] zeroCompressionTableData)
           
 long getZeroCompressionTableOffset()
           
 long rewriteData(OutputStream outputStream, long dataOffset)
           
 long rewriteEntry(OutputStream outputStream, long entryListOffset, long entryOffset, long dataOffset)
           
 byte[] unZeroCompressDataUsingTable(byte[] compactedByteArray, byte[] zeroCompressionTableByteArray)
           
 long updateData(LodResource lodResourceDataSource, OutputStream outputStream, long dataOffset)
           
protected  long updateDataHeader(LodResource lodResourceDataSource, OutputStream outputStream, long dataOffset, long uncompressedDataLength, long paletteNumber)
           
 long updateEntry(LodResource lodResourceDataSource, OutputStream outputStream, long entryListOffset, long entryOffset, long dataOffset)
           
private  long writeEntry(String name, long writtenDataLength, OutputStream outputStream, long entryListOffset, long entryOffset, long dataOffset)
           
 long writeNewData(LodResource lodResourceDataSource, OutputStream outputStream, long dataOffset)
           
protected  long writeNewDataHeader(LodResource lodResourceDataSource, OutputStream outputStream, long dataOffset, long uncompressedDataLength, long paletteNumber)
           
 long writeNewEntry(LodResource lodResourceDataSource, OutputStream outputStream, long entryListOffset, long entryOffset, long dataOffset)
           
private  byte[] zeroCompressDataIntoTable(int imageWidth, int imageHeight, byte[] uncompactedData, byte[] zeroCompressionTableData)
           
 
Methods inherited from class org.gamenet.application.mm8leveleditor.lod.LodEntry
compareTo, computeFileBasedOffsets, getDataHeader, getEntryHeader, getEntryOffset, getLodFile, getName, readDataHeader, readEntryHeader, readRawData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

thePassThroughLodFileExtractor

protected Extractor thePassThroughLodFileExtractor

theLodFileExtractor

protected Extractor theLodFileExtractor

ENTRY_NAME__ENTRY_HEADER_OFFSET

protected static final int ENTRY_NAME__ENTRY_HEADER_OFFSET
See Also:
Constant Field Values

ENTRY_NAME__ENTRY_HEADER_MAX_LENGTH

protected static final int ENTRY_NAME__ENTRY_HEADER_MAX_LENGTH
See Also:
Constant Field Values

DATA_SEGMENT_OFFSET__ENTRY_HEADER_OFFSET

protected static final int DATA_SEGMENT_OFFSET__ENTRY_HEADER_OFFSET
See Also:
Constant Field Values

DATA_SEGMENT_LENGTH__ENTRY_HEADER_OFFSET

protected static final int DATA_SEGMENT_LENGTH__ENTRY_HEADER_OFFSET
See Also:
Constant Field Values

DATA_NAME__DATA_HEADER_OFFSET

protected static final int DATA_NAME__DATA_HEADER_OFFSET
See Also:
Constant Field Values

DATA_NAME__DATA_HEADER_MAX_LENGTH

protected static final int DATA_NAME__DATA_HEADER_MAX_LENGTH
See Also:
Constant Field Values

TGA_BYTE_WIDTH__DATA_HEADER_OFFSET

protected static final int TGA_BYTE_WIDTH__DATA_HEADER_OFFSET
See Also:
Constant Field Values

TGA_BYTE_HEIGHT__DATA_HEADER_OFFSET

protected static final int TGA_BYTE_HEIGHT__DATA_HEADER_OFFSET
See Also:
Constant Field Values

PALETTE_NUMBER__DATA_HEADER_OFFSET

protected static final int PALETTE_NUMBER__DATA_HEADER_OFFSET
See Also:
Constant Field Values

UNKNOWN__DATA_HEADER_OFFSET

private static final int UNKNOWN__DATA_HEADER_OFFSET
See Also:
Constant Field Values

DATA_CONTENT_UNCOMPRESSED_SIZE__DATA_HEADER_OFFSET

private static final int DATA_CONTENT_UNCOMPRESSED_SIZE__DATA_HEADER_OFFSET
See Also:
Constant Field Values

DATA_HEADER_LENGTH

protected static final int DATA_HEADER_LENGTH
See Also:
Constant Field Values

ZERO_COMPRESSION_TABLE__DATA_HEADER_OFFSET

private static final int ZERO_COMPRESSION_TABLE__DATA_HEADER_OFFSET
See Also:
Constant Field Values

ZERO_COMPRESSION_TABLE_DATA_SIZE

private static final int ZERO_COMPRESSION_TABLE_DATA_SIZE
See Also:
Constant Field Values

ZERO_COMPRESSION_LINE_DATA_START_BYTE_OFFSET

private static final int ZERO_COMPRESSION_LINE_DATA_START_BYTE_OFFSET
See Also:
Constant Field Values

ZERO_COMPRESSION_LINE_DATA_END_BYTE_OFFSET

private static final int ZERO_COMPRESSION_LINE_DATA_END_BYTE_OFFSET
See Also:
Constant Field Values

ZERO_COMPRESSION_LINE_DATA_OFFSET_OFFSET

private static final int ZERO_COMPRESSION_LINE_DATA_OFFSET_OFFSET
See Also:
Constant Field Values

theFileExtractor

protected Extractor theFileExtractor
Constructor Detail

MM6SpritesLodEntry

public MM6SpritesLodEntry(LodFile lodFile,
                          long headerOffset)
                   throws IOException
Method Detail

getTextDescription

public String getTextDescription()
Specified by:
getTextDescription in interface LodResource

getByteWidth

public int getByteWidth()
Specified by:
getByteWidth in interface TGADataProducer
Returns:
image width in bytes

getByteHeight

public int getByteHeight()
Specified by:
getByteHeight in interface TGADataProducer
Returns:
image height in bytes

getZeroCompressionTableOffset

public long getZeroCompressionTableOffset()

getPalette

public int[] getPalette()
                 throws IOException
Specified by:
getPalette in interface TGADataProducer
Returns:
int array of palette data
Throws:
IOException

computeEntryBasedOffsets

protected void computeEntryBasedOffsets()
Specified by:
computeEntryBasedOffsets in class LodEntry

computeDataBasedOffsets

protected void computeDataBasedOffsets()
Specified by:
computeDataBasedOffsets in class LodEntry

getDataHeaderOffset

protected long getDataHeaderOffset()
Specified by:
getDataHeaderOffset in class LodEntry

getDataOffset

public long getDataOffset()
Specified by:
getDataOffset in class LodEntry

getDataLength

protected int getDataLength()
Specified by:
getDataLength in class LodEntry

getData

public byte[] getData()
               throws IOException
Specified by:
getData in interface LodResource
Throws:
IOException

getResourceType

public String getResourceType()
Specified by:
getResourceType in interface LodResource

getOffsetInEntryHeaderForDataSegmentOffset

protected int getOffsetInEntryHeaderForDataSegmentOffset()

getOffsetInEntryHeaderForDataSegmentLength

protected int getOffsetInEntryHeaderForDataSegmentLength()

getDataHeaderLength

protected int getDataHeaderLength()

getOffsetInDataHeaderForDataName

protected int getOffsetInDataHeaderForDataName()

getDataNameMaxLength

protected int getDataNameMaxLength()

getOffsetInDataHeaderForPaletteNumber

protected int getOffsetInDataHeaderForPaletteNumber()

getOffsetInDataHeaderForDataContentUncompressedLength

protected long getOffsetInDataHeaderForDataContentUncompressedLength()

getOffsetInDataHeaderForTGAByteWidth

protected int getOffsetInDataHeaderForTGAByteWidth()

getOffsetInDataHeaderForTGAByteHeight

protected int getOffsetInDataHeaderForTGAByteHeight()

getFileName

public String getFileName()
Specified by:
getFileName in class LodEntry

getFileType

protected String getFileType()

getEntryName

public String getEntryName()
Specified by:
getEntryName in class LodEntry

getDataName

public String getDataName()
Specified by:
getDataName in class LodEntry

getDataType

protected String getDataType()

getPaletteNumber

protected long getPaletteNumber()

getDecompressedSize

protected long getDecompressedSize()

getExtractor

protected Extractor getExtractor()

getFormatConverter

public FormatConverter getFormatConverter()
Overrides:
getFormatConverter in class LodEntry

getFormatConverterFileType

public String getFormatConverterFileType()
Overrides:
getFormatConverterFileType in class LodEntry

getNewWrittenDataContentLength

protected int getNewWrittenDataContentLength(LodResource lodResourceDataSource)

getUpdatedWrittenDataContentLength

protected int getUpdatedWrittenDataContentLength(LodResource lodResourceDataSource)

writeEntry

private long writeEntry(String name,
                        long writtenDataLength,
                        OutputStream outputStream,
                        long entryListOffset,
                        long entryOffset,
                        long dataOffset)
                 throws IOException
Throws:
IOException

rewriteEntry

public long rewriteEntry(OutputStream outputStream,
                         long entryListOffset,
                         long entryOffset,
                         long dataOffset)
                  throws IOException
Specified by:
rewriteEntry in class LodEntry
Throws:
IOException

writeNewEntry

public long writeNewEntry(LodResource lodResourceDataSource,
                          OutputStream outputStream,
                          long entryListOffset,
                          long entryOffset,
                          long dataOffset)
                   throws IOException
Specified by:
writeNewEntry in class LodEntry
Parameters:
outputStream -
entryOffset - to start writing the entry
dataOffset - to start writing the data for this entry
Returns:
dataOffset for next entry
Throws:
IOException

updateEntry

public long updateEntry(LodResource lodResourceDataSource,
                        OutputStream outputStream,
                        long entryListOffset,
                        long entryOffset,
                        long dataOffset)
                 throws IOException
Specified by:
updateEntry in class LodEntry
Throws:
IOException

writeNewDataHeader

protected long writeNewDataHeader(LodResource lodResourceDataSource,
                                  OutputStream outputStream,
                                  long dataOffset,
                                  long uncompressedDataLength,
                                  long paletteNumber)
                           throws IOException
Throws:
IOException

updateDataHeader

protected long updateDataHeader(LodResource lodResourceDataSource,
                                OutputStream outputStream,
                                long dataOffset,
                                long uncompressedDataLength,
                                long paletteNumber)
                         throws IOException
Throws:
IOException

writeNewData

public long writeNewData(LodResource lodResourceDataSource,
                         OutputStream outputStream,
                         long dataOffset)
                  throws IOException
Specified by:
writeNewData in class LodEntry
Parameters:
outputStream -
dataOffset - to start writing this datum
Returns:
dataOffset for next datum
Throws:
IOException

updateData

public long updateData(LodResource lodResourceDataSource,
                       OutputStream outputStream,
                       long dataOffset)
                throws IOException
Specified by:
updateData in class LodEntry
Throws:
IOException

rewriteData

public long rewriteData(OutputStream outputStream,
                        long dataOffset)
                 throws IOException
Specified by:
rewriteData in class LodEntry
Throws:
IOException

getZeroCompressionTable

public MM6SpritesLodEntry.ZeroCompressionTableEntry[] getZeroCompressionTable(byte[] zeroCompressionTableData)
                                                                       throws IOException
Throws:
IOException

zeroCompressDataIntoTable

private byte[] zeroCompressDataIntoTable(int imageWidth,
                                         int imageHeight,
                                         byte[] uncompactedData,
                                         byte[] zeroCompressionTableData)
Parameters:
uncompactedData -
zeroCompressionTableData -
Returns:

unZeroCompressDataUsingTable

public byte[] unZeroCompressDataUsingTable(byte[] compactedByteArray,
                                           byte[] zeroCompressionTableByteArray)
                                    throws IOException
Throws:
IOException