Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/waterbox/gpgx/core/macros.h
2 views
1
#ifndef _MACROS_H_
2
#define _MACROS_H_
3
4
#ifdef LSB_FIRST
5
6
#define READ_BYTE(BASE, ADDR) (BASE)[(ADDR)^1]
7
8
#define READ_WORD(BASE, ADDR) (((BASE)[ADDR]<<8) | (BASE)[(ADDR)+1])
9
10
#define READ_WORD_LONG(BASE, ADDR) (((BASE)[(ADDR)+1]<<24) | \
11
((BASE)[(ADDR)]<<16) | \
12
((BASE)[(ADDR)+3]<<8) | \
13
(BASE)[(ADDR)+2])
14
15
#define WRITE_BYTE(BASE, ADDR, VAL) (BASE)[(ADDR)^1] = (VAL)&0xff
16
17
#define WRITE_WORD(BASE, ADDR, VAL) (BASE)[ADDR] = ((VAL)>>8) & 0xff; \
18
(BASE)[(ADDR)+1] = (VAL)&0xff
19
20
#define WRITE_WORD_LONG(BASE, ADDR, VAL) (BASE)[(ADDR+1)] = ((VAL)>>24) & 0xff; \
21
(BASE)[(ADDR)] = ((VAL)>>16)&0xff; \
22
(BASE)[(ADDR+3)] = ((VAL)>>8)&0xff; \
23
(BASE)[(ADDR+2)] = (VAL)&0xff
24
25
#else
26
27
#define READ_BYTE(BASE, ADDR) (BASE)[ADDR]
28
#define READ_WORD(BASE, ADDR) *(uint16 *)((BASE) + (ADDR))
29
#define READ_WORD_LONG(BASE, ADDR) *(uint32 *)((BASE) + (ADDR))
30
#define WRITE_BYTE(BASE, ADDR, VAL) (BASE)[ADDR] = VAL & 0xff
31
#define WRITE_WORD(BASE, ADDR, VAL) *(uint16 *)((BASE) + (ADDR)) = VAL & 0xffff
32
#define WRITE_WORD_LONG(BASE, ADDR, VAL) *(uint32 *)((BASE) + (ADDR)) = VAL & 0xffffffff
33
#endif
34
35
/* C89 compatibility */
36
#ifndef M_PI
37
#define M_PI 3.14159265358979323846264338327f
38
#endif /* M_PI */
39
40
/* Set to your compiler's static inline keyword to enable it, or
41
* set it to blank to disable it.
42
* If you define INLINE in the makefile, it will override this value.
43
* NOTE: not enabling inline functions will SEVERELY slow down emulation.
44
*/
45
#ifndef INLINE
46
#define INLINE static __inline__
47
#endif /* INLINE */
48
49
#endif /* _MACROS_H_ */
50
51