/*---------------------------------------------------------------------------* Copyright (C) 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. *---------------------------------------------------------------------------*/ // gfdFormat.h // // Formats For Cafe Grafhics Binary Files (e.g; .gtx and .gsh). #ifndef _CAFE_GFD_FORMAT_H_ #define _CAFE_GFD_FORMAT_H_ #ifdef __cplusplus extern "C" { #endif // __cplusplus /// @addtogroup GFDFormatGroup /// @{ typedef struct _GFDShaders { GX2VertexShader *pVertexShader; ///< Pointer to GX2VertexShader structure GX2PixelShader *pPixelShader; ///< Pointer to GX2PixelShader structure GX2GeometryShader *pGeometryShader; ///< Pointer to GX2GeometryShader structure } GFDShaders; typedef struct _GFDShaders2 { u32 abiVersion; ///< ABI version. This must be set to \ref GFD_DLL_ABI_VERSION. GX2VertexShader *pVertexShader; ///< Pointer to GX2VertexShader structure GX2PixelShader *pPixelShader; ///< Pointer to GX2PixelShader structure GX2GeometryShader *pGeometryShader; ///< Pointer to GX2GeometryShader structure GX2ComputeShader *pComputeShader; ///< Pointer to GX2ComputeShader structure } GFDShaders2; typedef struct _GFDShadersSrc { u32 abiVersion; ///< ABI version. This must be set to \ref GFD_DLL_ABI_VERSION. const char *pVertexShader; ///< Pointer to GX2VertexShader source string const char *pPixelShader; ///< Pointer to GX2PixelShader source string const char *pGeometryShader; ///< Pointer to GX2GeometryShader source string const char *pComputeShader; ///< Pointer to GX2ComputeShader source string } GFDShadersSrc; /// \brief Header structure at the beginning of GFD files (gsh and gtx). typedef struct _GFDHeader { u32 magic; ///< magic number u32 size; ///< size of header in bytes - must match exactly, or header (and hence file) is unreadable u32 majorVersion; ///< major version number - must match exactly or header is unreadable u32 minorVersion; ///< minor version number - will warn if lower. GFDGPUVersion gpuVersion; ///< GPU version for which this file is designed for, cast to u32 (file is GPU dependent after all) GFDAlignMode alignMode; ///< align mode of this file. u32 reserved1; ///< reserved (should be 0) u32 reserved2; ///< reserved (should be 0) } GFDHeader; /// \brief Block header for each block in GFD files (gsh and gtx). /// /// A block is a contiguous section of data in the file of a given type. Each block is preceded /// by one of these block headers, which specify the block type, it's length, and it's major/minor version number. /// /// There are also two different counters in this header. /// - id is unique incrementing number among all the blocks. /// - typeIdx is unique among all the blocks of the same type. Used to find the Nth index of the block /// typedef struct _GFDBlockHeader { u32 magic; ///< Magic number for block headers u32 size; ///< Size of block header in bytes u32 majorVersion; ///< Major version number - must match exactly or this block is unreadable u32 minorVersion; ///< Minor version number - will warn if lower. GFDBlockType type; ///< Block type u32 dataSize; ///< Size of the following data block, in bytes. u32 id; ///< A unique identifier for this block, allowing it to be referenced by other blocks (currently 0) u32 typeIdx; ///< An incrementing index for each instance of a given type (currently 0) } GFDBlockHeader; // ------------------------------------------------ /// \brief Trailer for relocatable blocks in GFD files (gsh and gtx). /// /// This is really simple section at the end of every data block that contains pointers, /// that allows one to easily deserialize it. /// /// Main purpose of this is to point to the patch table. /// While were at it, point to the main structure and the string table. /// // ------------------------------------------------ typedef struct _GFDBlockRelocationHeader { u32 magic; ///< magic value u32 size; ///< size of this data structure. Must exactly match sizeof(GFDBlockRelocationHeader) u32 type; ///< type of the main data block u32 dataSize; ///< size of the main data section (allocate this size of contiguous memory) u32 dataOffset; ///< offset of the main data section in this block. Should almost always be 4 u32 stringTableCharNumber; ///< number of characters in the string table u32 stringTableOffset; ///< offset of string table in this block u32 basePatchAddress; ///< base address used in patches, normally pointer to beginning of file block. If zero, no patching has been done. u32 patchTableOffsetNumber; ///< number of offsets in the patch table u32 patchTableOffset; ///< offset of the patch table in this block } GFDBlockRelocationHeader; /// @} #ifdef __cplusplus } #endif // __cplusplus #endif // _CAFE_GFD_FORMAT_H_