view src/dmpack.h @ 2208:90ec1ec89c56

Revamp the palette handling in lib64gfx somewhat, add helper functions to lib64util for handling external palette file options and add support for specifying one of the "internal" palettes or external (.act) palette file to gfxconv and 64vw.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 14 Jun 2019 05:01:12 +0300
parents d674ddc0fc82
children 0115b3dd9064
line wrap: on
line source

/*
 * DMLib
 * -- PACK-file routines
 * Programmed and designed by Matti 'ccr' Hamalainen
 * (C) Copyright 2011-2015 Tecnic Software productions (TNSP)
 */
#ifndef DMPACK_H
#define DMPACK_H
#include "dmlib.h"


#define	DPACK_IDENT     "TNSPDPCK"      // Magic ident
#define	DPACK_VERSION   (0x0200)        // Version


typedef struct _DMPackEntry
{
    char    filename[DMRES_NAME_LEN + 1]; // +1 for NUL byte
    Uint64  offset;            // Offset in pack file
    Uint32  length;            // Compressed data length
    Uint32  size;              // Size of UNCOMPRESSED data
    Uint32  flags;             // Stored flags, see DMF_* in dmres.h

    Uint32  privFlags;  // PrivFlags are not stored
    struct _DMPackEntry *next, *prev;
} DMPackEntry;


typedef struct
{
    DMPackEntry *entries;
    char *  filename;          // Filename & path
    FILE *  file;              // File
} DMPackFile;


typedef struct __attribute__((__packed__))
{
    char    ident[8];          // Magic identifier
    Uint16  version;           // Version
    Uint32  dirEntries;        // Number of entries
    Uint64  dirOffset;         // Offset of the directory
} DMPackFileHeader;


DMPackEntry *  dmPackEntryNew();
void           dmPackEntryFree(DMPackEntry *);
void           dmPackEntryInsert(DMPackEntry **, DMPackEntry *);
void           dmPackEntryDelete(DMPackEntry **, DMPackEntry *);

DMPackEntry *  dmPackFind(DMPackEntry *list, const char *filename);

int            dmPackOpen(const char *, DMPackFile **, BOOL);
int            dmPackClose(DMPackFile *);
int            dmPackRead(DMPackFile *, const char *, Uint8 **, size_t *);


#endif // DMPACK_H