OpenSNES
Modern Open-Source SNES Development SDK
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1
20
21#ifndef OPENSNES_TYPES_H
22#define OPENSNES_TYPES_H
23
24/*============================================================================
25 * Fixed-Width Integer Types
26 *============================================================================*/
27
42
44typedef signed char s8;
45
47typedef unsigned char u8;
48
50typedef signed short s16;
51
53typedef unsigned short u16;
54
76#ifdef __OPENSNES__
77typedef signed long s32;
78#else
79typedef signed int s32;
80#endif
81
87#ifdef __OPENSNES__
88typedef unsigned long u32;
89#else
90typedef unsigned int u32;
91#endif
92 /* end of types group */
94
95/*============================================================================
96 * Volatile Types
97 *============================================================================*/
98
107
108typedef volatile u8 vu8;
109typedef volatile u16 vu16;
110typedef volatile u32 vu32;
111typedef volatile s8 vs8;
112typedef volatile s16 vs16;
113typedef volatile s32 vs32;
114
116
117/*============================================================================
118 * Boolean Type
119 *============================================================================*/
120
136
137/*
138 * Bool type compatibility:
139 * - C11 compilers (cproc) have built-in bool/_Bool
140 * - Legacy compilers (816-tcc) need typedef
141 * We check for __STDC_VERSION__ >= C99 as indicator of modern compiler
142 */
143#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
144typedef unsigned char bool;
145#define false 0
146#define true 1
147#endif
148
149/* SNES-specific TRUE/FALSE (0xFF for TRUE is common in SNES code) */
150#define FALSE 0
151#define TRUE 0xFF
152
154
155/*============================================================================
156 * Common Macros
157 *============================================================================*/
158
164
166#ifndef NULL
167#define NULL ((void*)0)
168#endif
169
185#define BIT(n) (1u << (n))
186
192#define LO_BYTE(x) ((u8)((x) & 0xFF))
193
199#define HI_BYTE(x) ((u8)(((x) >> 8) & 0xFF))
200
207#define MAKE_WORD(lo, hi) ((u16)(((u8)(hi) << 8) | (u8)(lo)))
208
212#define MIN(a, b) (((a) < (b)) ? (a) : (b))
213
217#define MAX(a, b) (((a) > (b)) ? (a) : (b))
218
225#define CLAMP(x, lo, hi) (((x) < (lo)) ? (lo) : (((x) > (hi)) ? (hi) : (x)))
226
232#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
233
235
236/*============================================================================
237 * Function Pointer Types
238 *============================================================================*/
239
245
247typedef void (*VoidFn)(void);
248
250
251#endif /* OPENSNES_TYPES_H */
unsigned char bool
Definition types.h:144
void(* VoidFn)(void)
Void function taking no arguments.
Definition types.h:247
signed int s32
32-bit signed integer (-2147483648 to 2147483647)
Definition types.h:79
unsigned int u32
32-bit unsigned integer (0 to 4294967295)
Definition types.h:90
signed char s8
8-bit signed integer (-128 to 127)
Definition types.h:44
signed short s16
16-bit signed integer (-32768 to 32767)
Definition types.h:50
unsigned short u16
16-bit unsigned integer (0 to 65535)
Definition types.h:53
unsigned char u8
8-bit unsigned integer (0 to 255)
Definition types.h:47
volatile s8 vs8
Definition types.h:111
volatile u8 vu8
Definition types.h:108
volatile u16 vu16
Definition types.h:109
volatile s32 vs32
Definition types.h:113
volatile s16 vs16
Definition types.h:112
volatile u32 vu32
Definition types.h:110