/[pcsx2_0.9.7]/trunk/pcsx2/RDebug/deci2_netmp.cpp
ViewVC logotype

Contents of /trunk/pcsx2/RDebug/deci2_netmp.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (show annotations) (download)
Tue Sep 7 03:24:11 2010 UTC (9 years, 5 months ago) by william
File size: 4208 byte(s)
committing r3113 initial commit again...
1 /* PCSX2 - PS2 Emulator for PCs
2 * Copyright (C) 2002-2010 PCSX2 Dev Team
3 *
4 * PCSX2 is free software: you can redistribute it and/or modify it under the terms
5 * of the GNU Lesser General Public License as published by the Free Software Found-
6 * ation, either version 3 of the License, or (at your option) any later version.
7 *
8 * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10 * PURPOSE. See the GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License along with PCSX2.
13 * If not, see <http://www.gnu.org/licenses/>.
14 */
15
16
17 #include "PrecompiledHeader.h"
18
19 #include "Common.h"
20 #include "deci2.h"
21
22 struct DECI2_NETMP_HEADER{
23 DECI2_HEADER h; //+00
24 u8 code, //+08
25 result; //+09
26 }; //=0A
27
28 struct DECI2_NETMP_CONNECT{
29 u8 priority, //+00
30 _pad; //+01
31 u16 protocol; //+02
32 }; //=04
33
34 char d2_message[100];
35 int d2_count=1;
36 DECI2_NETMP_CONNECT d2_connect[50]={0xFF, 0, 0x400};
37
38 void D2_NETMP(const u8 *inbuffer, u8 *outbuffer, char *message){
39 DECI2_NETMP_HEADER *in=(DECI2_NETMP_HEADER*)inbuffer,
40 *out=(DECI2_NETMP_HEADER*)outbuffer;
41 u8 *data=(u8*)in+sizeof(DECI2_NETMP_HEADER);
42 DECI2_NETMP_CONNECT *connect=(DECI2_NETMP_CONNECT*)data; //connect
43 int i, n;
44 static char p[100], line[1024];
45 u64 EEboot, IOPboot; //reset
46 u16 node;
47
48 memcpy(outbuffer, inbuffer, 128*1024);//BUFFERSIZE
49 out->h.length=sizeof(DECI2_NETMP_HEADER);
50 out->code++;
51 out->result=0; //ok
52 switch(in->code){
53 case 0:
54 n=(in->h.length-sizeof(DECI2_NETMP_HEADER)) / sizeof(DECI2_NETMP_CONNECT);
55 sprintf(line, "code=CONNECT");
56 for (i=0; i<n; i++){
57 sprintf(p, " %04X/%d", connect[i].protocol, connect[i].priority);
58 strcat(line, p);
59 }
60 memcpy(&d2_connect[n], connect, n*sizeof(DECI2_NETMP_CONNECT));
61 d2_count+=n;
62 writeData(outbuffer);
63 break;
64 case 2:
65 data+=2;
66 EEboot =*(u64*)data; data+=8;
67 IOPboot=*(u64*)data;
68 sprintf(line, "code=RESET EE=0x%I64X IOP=0x%I64X", EEboot, IOPboot);
69 ////////////////////////////hack
70 //data=(u8*)out+sizeof(DECI2_NETMP_HEADER);
71 //*data++=6;
72 //out->h.length=data-(u8*)out;
73 writeData(outbuffer);
74
75 node=(u16)'I';
76 sendDCMP(PROTO_DCMP, 'H', 'H', 2, 0, (char*)&node, sizeof(node));
77
78 node=(u16)'E';
79 sendDCMP(PROTO_DCMP, 'H', 'H', 2, 0, (char*)&node, sizeof(node));
80
81 node=PROTO_ILOADP;
82 sendDCMP(PROTO_DCMP, 'I', 'H', 2, 1, (char*)&node, sizeof(node));
83
84 for (i=0; i<10; i++){
85 node=PROTO_ETTYP+i;
86 sendDCMP(PROTO_DCMP, 'E', 'H', 2, 1, (char*)&node, sizeof(node));
87
88 node=PROTO_ITTYP+i;
89 sendDCMP(PROTO_DCMP, 'E', 'H', 2, 1, (char*)&node, sizeof(node));
90 }
91 node=PROTO_ETTYP+0xF;
92 sendDCMP(PROTO_DCMP, 'E', 'H', 2, 1, (char*)&node, sizeof(node));
93
94 node=PROTO_ITTYP+0xF;
95 sendDCMP(PROTO_DCMP, 'E', 'H', 2, 1, (char*)&node, sizeof(node));
96 break;
97 case 4://[OK]
98 sprintf(line, "code=MESSAGE %s", data);//null terminated by the memset with 0 call
99 strcpy(d2_message, (char*)data);
100 writeData(outbuffer);
101 break;
102 case 6://[ok]
103 sprintf(line, "code=STATUS");
104 data=(u8*)out+sizeof(DECI2_NETMP_HEADER)+2;
105 /*
106 memcpy(data, d2_connect, 1*sizeof(DECI2_NETMP_CONNECT));
107 data+=1*sizeof(DECI2_NETMP_CONNECT);
108 *(u32*)data=1;//quite fast;)
109 data+=4;
110 memcpy(data, d2_message, strlen(d2_message));
111 data+=strlen(d2_message);
112 *(u32*)data=0;//null end the string on a word boundary
113 data+=3;data=(u8*)((int)data & 0xFFFFFFFC);*/
114
115 out->h.length=data-(u8*)out;
116 writeData(outbuffer);
117 break;
118 case 8:
119 sprintf(line, "code=KILL protocol=0x%04X", *(u16*)data);
120 writeData(outbuffer);
121 break;
122 case 10:
123 sprintf(line, "code=VERSION %s", data);
124 data=(u8*)out+sizeof(DECI2_NETMP_HEADER);
125 strcpy((char*)data, "0.2.0");data+=strlen("0.2.0");//emu version;)
126 out->h.length=data-(u8*)out;
127 writeData(outbuffer);
128 break;
129 default:
130 sprintf(line, "code=%d[unknown] result=%d", in->code, in->result);
131 writeData(outbuffer);
132 }
133 sprintf(message, "[NETMP %c->%c/%04X] %s", in->h.source, in->h.destination, in->h.length, line);
134 }

  ViewVC Help
Powered by ViewVC 1.1.22