libc8
CHIP-8 utility library
Loading...
Searching...
No Matches
common.h
Go to the documentation of this file.
1
7#ifndef C8_COMMON_H
8#define C8_COMMON_H
9
10#ifdef TEST
11#define C8_STATIC
12#define C8_INLINE
13#else
14#define C8_STATIC static
15#define C8_INLINE inline
16#endif
17
18#ifndef C8_VERSION
22#define C8_VERSION "unknown"
23#endif
24
28#define C8_X(i) ((i & 0x0F00) >> 8)
29
33#define C8_Y(i) ((i & 0x00F0) >> 4)
34
38#define C8_NNN(i) (i & 0x0FFF)
39
43#define C8_A(i) ((i & 0xF000) >> 12)
44
48#define C8_B(i) (i & 0x000F)
49
53#define C8_KK(i) (i & 0x00FF)
54
58#define C8_EXPAND(i) \
59 uint8_t x = C8_X(i); \
60 uint8_t y = C8_Y(i); \
61 uint16_t nnn = C8_NNN(i); \
62 uint8_t a = C8_A(i); \
63 uint8_t b = C8_B(i); \
64 uint8_t kk = C8_KK(i);
65
69#define C8_PROG_START 0x200
70
74#define C8_MEMSIZE 0x1000
75
76#endif