-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCookieboyJoypad.h
67 lines (53 loc) · 1.1 KB
/
CookieboyJoypad.h
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef COOKIEBOYJOYPAD_H
#define COOKIEBOYJOYPAD_H
#include "CookieboyDefs.h"
#include <memory.h>
namespace Cookieboy
{
class Interrupts;
class Joypad
{
public:
struct ButtonsState
{
BYTE A;
BYTE B;
BYTE start;
BYTE select;
BYTE left;
BYTE right;
BYTE up;
BYTE down;
};
Joypad() { Reset(); }
void Step(Interrupts &INT);
void UpdateJoypad(ButtonsState &buttons) { Buttons = buttons; }
void Reset() { P1 = 0; memset(&Buttons, 0, sizeof(Buttons)); }
void EmulateBIOS() { Reset(); }
void P1Changed(BYTE value) { P1 = value; }
BYTE GetP1() { return P1 | 0xC0; }
private:
BYTE P1;//Register for reading joy pad info and determining system type
//Bit 7 - Not used
//Bit 6 - Not used
//Bit 5 - P15 out port
//Bit 4 - P14 out port
//Bit 3 - P13 in port
//Bit 2 - P12 in port
//Bit 1 - P11 in port
//Bit 0 - P10 in port
//
// P14 P15
// | |
//P10-----O-Right-----O-A
// | |
//P11-----O-Left------O-B
// | |
//P12-----O-Up--------O-Select
// | |
//P13-----O-Down------O-Start
// | |
ButtonsState Buttons;
};
}
#endif