llvm-mos-sdk
padlib.h
Go to the documentation of this file.
1 #ifndef _PADLIB_H
2 #define _PADLIB_H
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 // written by Doug Fraker 2019
9 // NES powerpad code
10 
11 // pass it 0 or 1, which port
12 // returns 2 byte value
13 __attribute((leaf)) unsigned read_powerpad(char pad);
14 
15 // for side B, powerpad
16 // ,---------+---------.
17 // | POWER PAD side B |
18 // | (1) (2) (3) (4) |
19 // | |
20 // | (5) (6) (7) (8) |
21 // | |
22 // | (9) (10)(11)(12) |
23 // | |
24 // `-------------------'
25 
26 // 4-2 3-1 12-5 8-9 x-6 x-10 x-11 x-7
27 
28 #define POWERPAD_4 0x8000
29 #define POWERPAD_2 0x4000
30 #define POWERPAD_3 0x2000
31 #define POWERPAD_1 0x1000
32 #define POWERPAD_12 0x0800
33 #define POWERPAD_5 0x0400
34 #define POWERPAD_8 0x0200
35 #define POWERPAD_9 0x0100
36 
37 #define POWERPAD_6 0x0040
38 #define POWERPAD_10 0x0010
39 #define POWERPAD_11 0x0004
40 #define POWERPAD_7 0x0001
41 
42 #ifdef __cplusplus
43 }
44 #endif
45 
46 #endif // _PADLIB_H