/*======================================================================
 *      sg_byFnt.h -- Font data
 *      Copyright(c) SEGA ENTERPRISES, LTD., 1998
 *      Ver.0.51(1998-07-09) Written by SEKI Masahiro
 *      Ver.0.60(1998-08-28) Added Shift JIS interface by SEKI Masahiro
 *======================================================================*/
#ifndef _SG_BTFNT_H_
#define _SG_BTFNT_H_

/*** Boot ROM Access interface ******************************************/
/*
 * each offset and each size in Boot ROM Font
 */
#define SYD_BT_FNT_ASCII_24_OFS  (0)
#define SYD_BT_FNT_ASCII_24_SIZE (96*12*24/8)
#define SYD_BT_FNT_WEST_24_OFS   (SYD_BT_FNT_ASCII_24_OFS+SYD_BT_FNT_ASCII_24_SIZE)
#define SYD_BT_FNT_WEST_24_SIZE  (96*12*24/8)
#define SYD_BT_FNT_JISX_24_OFS   (SYD_BT_FNT_WEST_24_OFS+SYD_BT_FNT_WEST_24_SIZE)
#define SYD_BT_FNT_JISX_24_SIZE  (96*12*24/8)
#define SYD_BT_FNT_KANA_24_OFS   (SYD_BT_FNT_JISX_24_OFS+SYD_BT_FNT_JISX_24_SIZE)
#define SYD_BT_FNT_KANA_24_SIZE  (47376)
#define SYD_BT_FNT_LVL1_24_OFS   (SYD_BT_FNT_KANA_24_OFS+SYD_BT_FNT_KANA_24_SIZE)
#define SYD_BT_FNT_LVL1_24_SIZE  (216576)
#define SYD_BT_FNT_LVL2_24_OFS   (SYD_BT_FNT_LVL1_24_OFS+SYD_BT_FNT_LVL1_24_SIZE)
#define SYD_BT_FNT_LVL2_24_SIZE  (244080)
#define SYD_BT_FNT_ASCII_12_OFS  (0)
#define SYD_BT_FNT_ASCII_12_SIZE (0)
#define SYD_BT_FNT_GAIJ_24_OFS   (0)
#define SYD_BT_FNT_GAIJ_24_SIZE  (0)
#define SYD_BT_FNT_VMSICON_OFS   (0)
#define SYD_BT_FNT_VMSICON_SIZE  (0)

#define SYD_BT_FNT_WORK_ASCII_24_OFS  SYD_BT_FNT_ASCII_24_OFS
#define SYD_BT_FNT_WORK_ASCII_24_SIZE SYD_BT_FNT_ASCII_24_SIZE
#define SYD_BT_FNT_WORK_WEST_24_OFS   SYD_BT_FNT_WEST_24_OFS
#define SYD_BT_FNT_WORK_WEST_24_SIZE  SYD_BT_FNT_WEST_24_SIZE
#define SYD_BT_FNT_WORK_JISX_24_OFS   SYD_BT_FNT_JISX_24_OFS
#define SYD_BT_FNT_WORK_JISX_24_SIZE  SYD_BT_FNT_JISX_24_SIZE
#define SYD_BT_FNT_WORK_KANA_24_OFS   SYD_BT_FNT_KANA_24_OFS
#define SYD_BT_FNT_WORK_KANA_24_SIZE  SYD_BT_FNT_KANA_24_SIZE
#define SYD_BT_FNT_WORK_LVL1_24_OFS   SYD_BT_FNT_LVL1_24_OFS
#define SYD_BT_FNT_WORK_LVL1_24_SIZE  SYD_BT_FNT_LVL1_24_SIZE
#define SYD_BT_FNT_WORK_LVL2_24_OFS   SYD_BT_FNT_LVL2_24_OFS
#define SYD_BT_FNT_WORK_LVL2_24_SIZE  SYD_BT_FNT_LVL2_24_SIZE
#define SYD_BT_FNT_WORK_ASCII_12_OFS  SYD_BT_FNT_ASCII_12_OFS
#define SYD_BT_FNT_WORK_ASCII_12_SIZE SYD_BT_FNT_ASCII_12_SIZE
#define SYD_BT_FNT_WORK_GAIJ_24_OFS   SYD_BT_FNT_GAIJ_24_OFS
#define SYD_BT_FNT_WORK_GAIJ_24_SIZE  SYD_BT_FNT_GAIJ_24_SIZE

/*
 * pixels of font
 */
#define SYD_BT_FNT_24_WIDTH_HAN (12)
#define SYD_BT_FNT_24_WIDTH_ZEN (24)
#define SYD_BT_FNT_24_HEIGHT    (24)
#define SYD_BT_FNT_12_WIDTH     (0)
#define SYD_BT_FNT_12_HEIGHT    (0)
#define SYD_BT_FNT_24_SIZE_HAN  (SYD_BT_FNT_24_WIDTH_HAN * SYD_BT_FNT_24_HEIGHT / 8)
#define SYD_BT_FNT_24_SIZE_ZEN  (SYD_BT_FNT_24_WIDTH_ZEN * SYD_BT_FNT_24_HEIGHT / 8)
#define SYD_BT_FNT_12_SIZE      (SYD_BT_FNT_12_WIDTH * SYD_BT_FNT_12_HEIGHT / 8)

#define SYD_BT_FNTINI    (0)

#define SYD_BT_FNT_SMPH_SUCCESS (0)
#define SYD_BT_FNT_SMPH_FAILURE (-1)

extern void *syBtFntGet( Uint32 num );
extern Sint32 syBtFntChkSmph( void );
extern void syBtFntClrSmph( void );


/*** Shift JIS code interface *******************************************/
/*
 * ascii code information and SJIS code information
 */
#define SYD_BT_FNT_CODE_ASCII_MIN (0x0020)
#define SYD_BT_FNT_CODE_ASCII_MAX (0x007f)
#define SYD_BT_FNT_CODE_8BIT_MIN  (0x00a0)
#define SYD_BT_FNT_CODE_8BIT_MAX  (0x00ff)
#define SYD_BT_FNT_CODE_KANA_MIN  (0x8140)
#define SYD_BT_FNT_CODE_KANA_MAX  (0x8396)
#define SYD_BT_FNT_CODE_LVL1_MIN  (0x889f)
#define SYD_BT_FNT_CODE_LVL1_MAX  (0x9872)
#define SYD_BT_FNT_CODE_LVL2_MIN  (0x989f)
#define SYD_BT_FNT_CODE_LVL2_MAX  (0xeaa4)
#define SYD_BT_FNT_JIS_SPACE      (0x2121)
#define SYD_BT_FNT_SJIS_SPACE     (0x8140)
#define SYD_BT_FNT_ASCII_SPACE    (0x20)
#define SYD_BT_FNT_SJIS_GETA      (0x81ac)

#define SYD_BT_FNT_FIRSTINDEX_LVL1 ((0x0030-0x0021)*((0x007e)-0x0021+1)+(0x0021-0x0021))
#define SYD_BT_FNT_FIRSTINDEX_LVL2 ((0x0050-0x0021)*((0x007e)-0x0021+1)+(0x0021-0x0021))

typedef struct tag_SYS_BT_FNT_INFO {
	Uint8  width;                     /* Width of a font graphic          */
	Uint8  height;                    /* Height of a font graphic         */
} SYS_BT_FNT_INFO;

typedef enum {
	SYE_BT_FNT_FONTSET_WESTERN_24,              /* ISO 8859-1 12x24      */
	SYE_BT_FNT_FONTSET_JP_JIS_24,               /* JIS X 0201 12x24      */
	SYE_BT_FNT_FONTSET_JP_KANA_24,              /* Shift JIS 24x24       */
	SYE_BT_FNT_FONTSET_JP_LVL1_24,              /* Shift JIS 24x24       */
	SYE_BT_FNT_FONTSET_JP_LVL2_24,              /* Shift JIS 24x24       */
	SYE_BT_FNT_FONTSET_END,
	SYE_BT_FNT_FONTSET_JP_ASCII_12 = 0,         /* Shift JIS 24x24       */
	SYE_BT_FNT_FONTSET_JP_ASCII_JP_12 = 0,      /* ASCII yen, overline   */
	SYE_BT_FNT_FONTSET_JP_GAIJ_24 = 0           /* SEGA specific font    */
} SYE_BT_FNT_FONTSET;

/*** Basic functions *****************************************************/
Uint32 syBtFntGetAddr( SYE_BT_FNT_FONTSET set, Sint16 code );
void syBtFntGetInfo( SYE_BT_FNT_FONTSET set, Sint16 code, SYS_BT_FNT_INFO *info );
/*** Utility functions ***************************************************/
Sint16 syBtFntSjis2Jis( Sint16 sjis );

#endif /* _SG_BTFNT_H_ */
