3 * @brief 変愚蛮怒で新しく追加された主要なマクロ定義ヘッダ / Define some simple constants
9 #ifndef INCLUDED_H_DEFINE_H
10 #define INCLUDED_H_DEFINE_H
17 # define NULL ((void*)0) /*!< コンパイル環境に定義がない場合のNULL定義 */
19 # define NULL ((char*)0) /*!< コンパイル環境に定義がない場合のNULL定義 */
20 # endif /* __STDC__ */
25 * Hack -- assist "main-acn.c"
35 * Hack -- force definitions -- see fd_seek()
48 * Hack -- force definitions -- see fd_lock()
62 * The constants "TRUE" and "FALSE"
66 #define TRUE 1 /*!< コンパイル環境に定義がない場合のTRUE定義 */
69 #define FALSE 0 /*!< コンパイル環境に定義がない場合のFALSE定義 */
74 /**** Simple "Macros" ****/
77 #define lbtokg(x) ((int)(((x)*4536)/1000)) /*!< Zangband基準のポンド→キログラム変換定義(全体) */
78 #define lbtokg1(x) ((lbtokg(x)+5)/100) /*!< Zangband基準のポンド→キログラム変換定義(整数部) */
79 #define lbtokg2(x) ( ( (lbtokg(x)+5)%100)/10) /*!< Zangband基準のポンド→キログラム変換定義(少数部) */
81 #define lbtokg(x) ((int)((x)*5)) /*!< 変愚蛮怒基準のポンド→キログラム変換定義(全体) */
82 #define lbtokg1(x) (lbtokg(x)/100) /*!< 変愚蛮怒基準のポンド→キログラム変換定義(整数部) */
83 #define lbtokg2(x) ((lbtokg(x)%100)/10) /*!< 変愚蛮怒基準のポンド→キログラム変換定義(少数部) */
87 * Force a character to lowercase/uppercase
89 #define FORCELOWER(A) ((isupper((A))) ? tolower((A)) : (A))
90 #define FORCEUPPER(A) ((islower((A))) ? toupper((A)) : (A))
94 * Non-typed minimum value macro
97 #define MIN(a,b) (((a) > (b)) ? (b) : (a))
100 * Non-typed maximum value macro
103 #define MAX(a,b) (((a) < (b)) ? (b) : (a))
106 * Non-typed absolute value macro
109 #define ABS(a) (((a) < 0) ? (-(a)) : (a))
112 * Non-typed sign extractor macro
115 #define SGN(a) (((a) < 0) ? (-1) : ((a) != 0))
119 * Hack -- allow use of "ASCII" and "EBCDIC" for "indexes", "digits",
120 * and "Control-Characters".
122 * Note that all "index" values must be "lowercase letters", while
123 * all "digits" must be "digits". Control characters can be made
124 * from any legal characters.
126 #define A2I(X) ((X) - 'a')
127 #define I2A(X) ((char)(X) + 'a')
128 #define D2I(X) ((X) - '0')
129 #define I2D(X) ((X) + '0')
130 #define KTRL(X) ((X) & 0x1F)
131 #define ESCAPE '\033'
134 * Refer to the member at offset of structure
136 #define atoffset(TYPE, STRUCT_PTR, OFFSET) (*(TYPE*)(((char*)STRUCT_PTR) + (OFFSET)))