/*---------------------------------------------------------------------------*
  Project:  NITRO-System - build - demos - g2d - Text - textdemolib
  File:     txt.h

  Copyright 2005 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.

  $Log: txt.h,v $
  Revision 1.3  05/30/2005 10:17:05  hatamoto_minoru
  Changed from ISO8859 to CP1252.

  Revision 1.2  05/23/2005 06:17:12  hatamoto_minoru
  Added an ISO-8859-1 encoding font.

  Revision 1.1  05/20/2005 05:52:38  hatamoto_minoru
  Registered in NitroSystem.

  Revision 1.9  03/28/2005 02:15:09  hatamoto_minoru
  Added TXT_LoadFile.

  Revision 1.8  03/18/2005 09:19:46  hatamoto_minoru
  Added support for the changes to the API.

  Revision 1.7  03/10/2005 08:18:55  hatamoto_minoru
  Added support for the changes to the API.
  Added comments.

  Revision 1.6  02/08/2005 09:52:51  hatamoto_minoru
  Revised the user color name to what is in the programming manual.

  Revision 1.5  02/08/2005 04:06:59  hatamoto_minoru
  Revised file headers.

  Revision 1.4  02/04/2005 00:15:13  hatamoto_minoru
  Replaced font data.

  Revision 1.3  02/01/2005 11:53:15  hatamoto_minoru
  Added shared color palette definitions.
  Added comments.

  Revision 1.2  01/25/2005 01:42:45  hatamoto_minoru
  Added XT_SetCharCanvasOBJAttrs().

  Revision 1.1  01/21/2005 01:03:09  hatamoto_minoru
  Registered to TextDraw.

  $NoKeywords: $
 *---------------------------------------------------------------------------*/
#ifndef TEXT_H_
#define TEXT_H_

#include <nnsys/g2d/g2d_Font.h>

#ifdef __cplusplus
extern "C" {
#endif

// Upper left alignment on DrawText
#define TXT_DRAWTEXT_FLAG_DEFAULT   (NNS_G2D_VERTICALORIGIN_TOP | NNS_G2D_HORIZONTALORIGIN_LEFT | NNS_G2D_HORIZONTALALIGN_LEFT)

// Font resource names for the demo
#define TXT_FONTRESOURCE_NAME               "/data/fonts.NFTR"
#define TXT_SJIS_FONTRESOURCE_NAME          "/data/fonts.NFTR"
#define TXT_UTF8_FONTRESOURCE_NAME          "/data/fontu8.NFTR"
#define TXT_UTF16_FONTRESOURCE_NAME         "/data/fontu16.NFTR"
#define TXT_CP1252_FONTRESOURCE_NAME        "/data/font1252.NFTR"



// Assumed to be loaded to the color name 16-color palette of TXTColorPalette
enum
{
    // palette 0 TXT_CPALETTE_MAIN
    TXT_COLOR_NULL=0,
    TXT_COLOR_WHITE,
    TXT_COLOR_BLACK,
    TXT_COLOR_RED,
    TXT_COLOR_GREEN,
    TXT_COLOR_BLUE,
    TXT_COLOR_CYAN,
    TXT_COLOR_MAGENTA,
    TXT_COLOR_YELLOW,

    // palette 1 TXT_CPALETTE_USERCOLOR
    TXT_UCOLOR_NULL=0,
    TXT_UCOLOR_GRAY,
    TXT_UCOLOR_BROWN,
    TXT_UCOLOR_RED,
    TXT_UCOLOR_PINK,
    TXT_UCOLOR_ORANGE,
    TXT_UCOLOR_YELLOW,
    TXT_UCOLOR_LIMEGREEN,
    TXT_UCOLOR_DARKGREEN,
    TXT_UCOLOR_SEAGREEN,
    TXT_UCOLOR_TURQUOISE,
    TXT_UCOLOR_BLUE,
    TXT_UCOLOR_DARKBLUE,
    TXT_UCOLOR_PURPLE,
    TXT_UCOLOR_VIOLET,
    TXT_UCOLOR_MAGENTA
};

// Assumed to be loaded to the palette name 16-color palette of TXTColorPalette
enum
{
    TXT_CPALETTE_MAIN,
    TXT_CPALETTE_USERCOLOR
};

// Shared color palette data
extern GXRgb TXTColorPalette[32];



//****************************************************************************
//
//****************************************************************************

/*---------------------------------------------------------------------------*
  Name:         TXT_Init

  Description:  Shared initialization of the sample.

  Arguments:    None.

  Returns:      None.
 *---------------------------------------------------------------------------*/
void TXT_Init(void);



/*---------------------------------------------------------------------------*
  Name:         TXT_SetupBackground

  Description:  Loads and displays the background image to the main screen BG0.

  Arguments:    None.

  Returns:      None.
 *---------------------------------------------------------------------------*/
void TXT_SetupBackground( void );



/*---------------------------------------------------------------------------*
  Name:         TXT_Alloc

  Description:  Allocates memory.

  Arguments:    size:   The size of the memory to allocate.

  Returns:      Pointer to the allocated memory region.
 *---------------------------------------------------------------------------*/
void* TXT_Alloc(u32 size);



/*---------------------------------------------------------------------------*
  Name:         TXT_Free

  Description:  Deallocates the memory allocated with TXT_Alloc().

  Arguments:    ptr:    Pointer to the memory region to deallocate.

  Returns:      None.
 *---------------------------------------------------------------------------*/
void TXT_Free(void* ptr);



/*---------------------------------------------------------------------------*
  Name:         TXT_SetCharCanvasOBJAttrs

  Description:  Configures all the parameters not configured by NNS_G2dArrangeOBJ*
                of continuous OAMs.

  Arguments:    None.

  Returns:      None.
 *---------------------------------------------------------------------------*/
void TXT_SetCharCanvasOBJAttrs(
    GXOamAttr * oam,
    int num,
    int priority,
    GXOamMode mode,
    BOOL mosaic,
    GXOamEffect effect,
    int cParam,
    int rsParam
);



/*---------------------------------------------------------------------------*
  Name:         TXT_LoadFont

  Description:  Loads a font from a file into memory.

  Arguments:    pFname: The font resource path.

  Returns:      The pointer to the loaded font.
 *---------------------------------------------------------------------------*/
void TXT_LoadFont( NNSG2dFont* pFont, const char* pFname );



/*---------------------------------------------------------------------------*
  Name:         TXT_LoadFile

  Description:  Loads a file to memory.

  Arguments:    ppFile: Pointer to the buffer that receives the memory address
                        that loads the file.
                fpath:  The path of the file to load.

  Returns:      Returns the file size of the loaded file.
                If the file size is 0, this indicates that the file failed to load.
                In that case, the *ppFile value is invalid.
 *---------------------------------------------------------------------------*/
u32 TXT_LoadFile(void** ppFile, const char* fpath);





#ifdef __cplusplus
}/* extern "C"*/
#endif

#endif // TEXT_H_


