forked from Zero1UP/PS2-Memory-Card-Formatter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmtaphelper.c
115 lines (100 loc) · 2.33 KB
/
mtaphelper.c
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// MTPT,mtP = Multitap Port
// mtRV = Multitap Retured Value
// Global Variable Used to Determine if the mtGO Function has already been used.
int MtapOPEN;
void mtOpenV()
{
MtapOPEN = 1;
}
// Closes Multitap Ports Automatically if mtGO() is called when multitap ports are already open in case you need to call mtGO() again.
void mtCloseP()
{
int MTPT;
for (MTPT =0; MTPT<4; MTPT++)
{
mtapPortClose(MTPT);
}
}
// A Simple For Loop To Handle Opening and Closing MultiTap ports.
void mtGO()
{
int MTPT;
// Close All MTAP Ports Automatically if This Function has Already Been Called
if(MtapOPEN == 1)
{
mtCloseP();
}
mtOpenV();
for (MTPT =0; MTPT<4; MTPT++)
{
mtDetect(MTPT);
}
}
/*
The mtDetect() Function Will Handle Detection of The Multitap and will also handle closing the port if it is not connected,
Usage: mtDetect(<MTAP Port number>) [0,1,2,3]
Example:mtDetect(1);
WARNING: calling this function without specifying the MTAP Port Number as ang ARG will Crash the PS2!
Using a Negative Number (-1) or a Number Greater then 4 Will Also Result In a Crash!
*/
void mtDetect(int mtP)
{
/*
Definitions
MTPT,mtP = Multitap Port
mtRV = Multitap Retured Value
*/
int mtRV;
char *CP = "Controller Port";
char *MCP = "Memory Card Port";
char *mtD = "Multi-tap Detected! \n";
char *mtND = "Multi-tap is Not Connected. \n";
//printf("Multitap Status:\n");
if (mtP ==0 || mtP ==1 || mtP ==2 || mtP ==3)
{
mtapPortOpen(mtP);
mtRV = mtapGetConnection(mtP);
if (mtRV == 1)
{
printf("Multitap Detected Port %d Opened.\n", mtP);
if (mtP == 0)
{
scr_printf("%s 0: %s",CP ,mtD);
}
if (mtP == 1)
{
scr_printf("%s 1: %s",CP, mtD);
}
if (mtP ==2)
{
scr_printf("%s 0: %s",MCP ,mtD);
}
if (mtP ==3)
{
scr_printf("%s 1: %s",MCP, mtD);
}
}
else
{
printf("Mutitap Not Connected!\n");
if (mtP == 0)
{
scr_printf("%s 0: %s",CP ,mtND);
}
if (mtP == 1)
{
scr_printf("%s 1: %s",CP, mtND);
}
if (mtP ==2)
{
scr_printf("%s 0: %s",MCP ,mtND);
}
if (mtP ==3)
{
scr_printf("%s 1: %s",MCP, mtND);
}
//Close MTAP Port if No Multitap is Connected
mtapPortClose(mtP);
}
}
}