/*--------------------------------------------------------------------------
  Project:  Manual 2D Library - m2d
  File:     resources.h

  Copyright (C)2007-2009 Nintendo  All Rights Reserved.

  These coded instructions, statements, and computer programs contain
  proprietary information of Nintendo of America Inc. and/or Nintendo
  Company Ltd., and are protected by Federal copyright law. They may
  not be disclosed to third parties or copied or duplicated in any form,
  in whole or in part, without the prior written consent of Nintendo.

  $Revision: 1.57 $
 *-------------------------------------------------------------------------*/

#ifndef NTMV_M2D_RESOURCES_H_
#define NTMV_M2D_RESOURCES_H_

#if _MSC_VER > 1000 || defined(__CWCC__)
#pragma once
#endif

#include <nitro/types.h>
#include <ntmv/m2d/types.h>

namespace ntmv
{
namespace m2d
{
namespace res
{


/* ========================================================================
    Constant Definitions
   ======================================================================== */

const u8    FileBinaryFileFormatMajorVersion    = 2;
const u8    FirstBinaryFileFormatMinorVersion   = 0;
const u8    LatestBinaryFileFormatMinorVersion  = 0;

const u16   BinaryFileFormatVersion     = u16((FileBinaryFileFormatMajorVersion << 8) + LatestBinaryFileFormatMinorVersion);
const u16   ByteOrderMark           = 0xfeff;

const u32   DATABLOCKKIND_NAMEPOOL      = 'nap1';   // Block header for the filename string pool

const u32   DATABLOCKKIND_TEXTPOOL      = 'txp1';   // Block header for the text string pool


/* ========================================================================
    Type Definitions
   ======================================================================== */

struct BinaryFileHeader
{
    char                signature[4];
    detail::ResU16      byteOrder;
    detail::ResU16      version;
    detail::ResU32      fileSize;
    detail::ResU16      headerSize;
    detail::ResU16      dataBlocks;
};

struct DataBlockHeader
{
    char                kind[4];
    detail::ResU32      size;
};

/*
    Block for the name string pool
*/
struct NameBlock
{
    DataBlockHeader     blockHeader;

    detail::ResU16      num;
    u8                  padding[2];

    detail::ResU32      offsets[/* num + 1 */];

    //  u8                  namePool[];
};

/*
    Block for the text string pool
*/
struct TextBlock
{
    DataBlockHeader     blockHeader;

    detail::ResU16      num;
    u8                  padding[2];

    detail::ResU32      offsets[/* num + 1 */];

    //  detail::ResU16      textPool[];
};

}   // namespace res
}   // namespace m2d
}   // namespace ntmv

/* NTMV_M2D_RESOURCES_H_ */
#endif
