Hengband  2.1.4
 全て データ構造 ファイル 関数 変数 型定義 マクロ定義 ページ
h-define.h
説明を見る。
1 /*!
2  * @file h-define.h
3  * @brief 変愚蛮怒で新しく追加された主要なマクロ定義ヘッダ / Define some simple constants
4  * @date 2014/08/16
5  * @author
6  * 不明(変愚蛮怒開発チーム?)
7  */
8 
9 #ifndef INCLUDED_H_DEFINE_H
10 #define INCLUDED_H_DEFINE_H
11 
12 /*
13  * Hack -- Define NULL
14  */
15 #ifndef NULL
16 # ifdef __STDC__
17 # define NULL ((void*)0) /*!< コンパイル環境に定義がない場合のNULL定義 */
18 # else
19 # define NULL ((char*)0) /*!< コンパイル環境に定義がない場合のNULL定義 */
20 # endif /* __STDC__ */
21 #endif /* NULL */
22 
23 
24 /*
25  * Hack -- assist "main-acn.c" XXX XXX XXX
26  */
27 #ifdef ACORN
28 # define O_RDONLY 0
29 # define O_WRONLY 1
30 # define O_RDWR 2
31 #endif
32 
33 
34 /*
35  * Hack -- force definitions -- see fd_seek()
36  */
37 #ifndef SEEK_SET
38 # define SEEK_SET 0
39 #endif
40 #ifndef SEEK_CUR
41 # define SEEK_CUR 1
42 #endif
43 #ifndef SEEK_END
44 # define SEEK_END 2
45 #endif
46 
47 /*
48  * Hack -- force definitions -- see fd_lock() XXX XXX XXX
49  */
50 #ifndef F_UNLCK
51 # define F_UNLCK 0
52 #endif
53 #ifndef F_RDLCK
54 # define F_RDLCK 1
55 #endif
56 #ifndef F_WRLCK
57 # define F_WRLCK 2
58 #endif
59 
60 
61 /*
62  * The constants "TRUE" and "FALSE"
63  */
64 
65 #undef TRUE
66 #define TRUE 1 /*!< コンパイル環境に定義がない場合のTRUE定義 */
67 
68 #undef FALSE
69 #define FALSE 0 /*!< コンパイル環境に定義がない場合のFALSE定義 */
70 
71 
72 
73 
74 /**** Simple "Macros" ****/
75 
76 #ifdef ZANGBAND_JP
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基準のポンド→キログラム変換定義(少数部) */
80 #elif defined(JP)
81 #define lbtokg(x) ((int)((x)*5)) /*!< 変愚蛮怒基準のポンド→キログラム変換定義(全体) */
82 #define lbtokg1(x) (lbtokg(x)/100) /*!< 変愚蛮怒基準のポンド→キログラム変換定義(整数部) */
83 #define lbtokg2(x) ((lbtokg(x)%100)/10) /*!< 変愚蛮怒基準のポンド→キログラム変換定義(少数部) */
84 #endif
85 
86 /*
87  * Force a character to lowercase/uppercase
88  */
89 #define FORCELOWER(A) ((isupper((A))) ? tolower((A)) : (A))
90 #define FORCEUPPER(A) ((islower((A))) ? toupper((A)) : (A))
91 
92 
93 /*
94  * Non-typed minimum value macro
95  */
96 #undef MIN
97 #define MIN(a,b) (((a) > (b)) ? (b) : (a))
98 
99 /*
100  * Non-typed maximum value macro
101  */
102 #undef MAX
103 #define MAX(a,b) (((a) < (b)) ? (b) : (a))
104 
105 /*
106  * Non-typed absolute value macro
107  */
108 #undef ABS
109 #define ABS(a) (((a) < 0) ? (-(a)) : (a))
110 
111 /*
112  * Non-typed sign extractor macro
113  */
114 #undef SGN
115 #define SGN(a) (((a) < 0) ? (-1) : ((a) != 0))
116 
117 
118 /*
119  * Hack -- allow use of "ASCII" and "EBCDIC" for "indexes", "digits",
120  * and "Control-Characters".
121  *
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. XXX XXX XXX
125  */
126 #ifdef VM
127 # define A2I(X) alphatoindex(X)
128 # define I2A(X) indextoalpha(X)
129 # define D2I(X) ((X) - '0')
130 # define I2D(X) ((X) + '0')
131 # define KTRL(X) ((X) & 0x1F)
132 # define ESCAPE '\033'
133 #else
134 # define A2I(X) ((X) - 'a')
135 # define I2A(X) ((X) + 'a')
136 # define D2I(X) ((X) - '0')
137 # define I2D(X) ((X) + '0')
138 # define KTRL(X) ((X) & 0x1F)
139 # define ESCAPE '\033'
140 #endif
141 
142 /*
143  * Refer to the member at offset of structure
144  */
145 #define atoffset(TYPE, STRUCT_PTR, OFFSET) (*(TYPE*)(((char*)STRUCT_PTR) + (OFFSET)))
146 
147 #endif
148