-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNes-Controller.txt
33 lines (26 loc) · 1.57 KB
/
Nes-Controller.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Nes Controller
Each switch can be mapped to a bit in a byte, so that 1 is "pressed" and 0 is "not pressed".
There are eight switches, so the controller state fits into a single byte:
|-----------|-------|------|------|------|-------|--------|-----|-----|
| Bit index | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|-----------|-------|------|------|------|-------|--------|-----|-----|
| Switch | right | left | down | up | start | select | B | A |
|-----------|-------|------|------|------|-------|--------|-----|-----|
// poll controller i (0-1)
pad = pad_poll(i);
// reads controller i in trigger mode
pad = pad_trigger(i);
// gets the last known state of controller input
pad pad_state(i);
|------------------------------------------------------------------|
| U |
| /\ |
| | |
| |Joypad |
| L <- - -O- - -> R select start |
| | |--------| |--------| |------| |------| |
| | |--------| |--------| | B | | A | |
| \/ |------| |------| |
| D |
| |
|------------------------------------------------------------------|